var t = require("../../../@babel/runtime/helpers/interopRequireDefault");

require("../../../@babel/runtime/helpers/Objectvalues");

var e = require("../../../@babel/runtime/helpers/defineProperty"), a = t(require("../../../@babel/runtime/regenerator")), i = require("../../../@babel/runtime/helpers/asyncToGenerator"), s = t(require("../../../dist/toast/toast")), o = t(require("../../../utils/util.js")), r = require("../../../mybehaviors/location/location"), d = getApp();

Page({
    behaviors: [ r ],
    data: {
        noSupportDispatch: [],
        plugin_id: "",
        isDomain: !1,
        clicktag: 0,
        language: "",
        pre_order_url: "",
        order_url: "",
        order_other_json: {},
        isCartsOrder: !1,
        options: {},
        _root_tag: "",
        TAG_ACTION_BUY: "-2",
        TAG_ACTION_CART: "-1",
        _goodsId: "",
        _optionsId: "",
        _total: 1,
        _cart_ids: [],
        currentAddId: "",
        currentAddress: {},
        store_id: 0,
        storeCarts: [],
        store_info: {},
        linkinfo: {
            mobile: "",
            name: ""
        },
        selectedMode: 0,
        selected: 0,
        dispatch: [],
        cup_notice: !0,
        isShowCoupon: !1,
        defaultAddress: {},
        realname: "",
        mobile: "",
        address: "",
        order_data: "",
        dispatch_price: 0,
        goods_price: 0,
        price: 0,
        discount_price: 0,
        deduction_price: 0,
        goodsInfo: {},
        popupCouponSpecs: !1,
        checkCouponList: [],
        coupon_size: 0,
        use_coupon_size: 0,
        coupons: [],
        checkDeductionList: [],
        myRealname: "",
        myIdcard: "",
        showMyinfo: !1,
        showFrom: !1,
        currentIndex: "999",
        isOpenRight: !1,
        isRightChoose: !1,
        isRent: !1,
        rentTime: [],
        rentFree: "",
        rent_deposit_free: 0,
        agreeCon: {},
        rent_free: 0,
        rentShow: !1,
        tenancy: "",
        note: {},
        isTaxGoods: !1,
        agreement: !1,
        agreementShow: !1,
        submit_active: !0,
        AgreementPay: "",
        agreementPay: !1,
        agreementPayShow: !1,
        _show_address: !1,
        isShowInvoice: !0,
        invoiceData: {
            papery_status: "",
            electron_status: ""
        },
        invoice_list: {},
        total_items: [],
        discount_amount_items: [],
        service_fee_items: [],
        tax_fee_items: {},
        service: {},
        isCash: "",
        goodsId: "",
        show1: !1,
        isOpenTeam: !1,
        isJoinTeam: !1,
        point: {
            lat: "",
            lng: ""
        },
        city: "",
        defaultSelfCarry: {},
        diyShow: !1,
        orders_goods: {},
        diyform: {
            form_id: "",
            diyform_data_id: "",
            pre_id: ""
        },
        markers_2: [ {
            latitude: "",
            longitude: "",
            iconPath: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
            width: 20,
            height: 25,
            callout: {
                padding: "10rpx",
                borderRadius: "5rpx"
            }
        } ],
        polygons_2: [ {
            points: [],
            fillColor: "#FF88887F",
            strokeColor: "#FFF",
            strokeWidth: 2,
            zIndex: 1
        } ],
        deliveryScopeShow: !1,
        default_member_address: "",
        delivery: {
            longitude: "113.324520",
            latitude: "23.099994"
        },
        delivery_note: "",
        delivery_area: [ [ 116.403322, 39.920255 ] ],
        locations: [ 116.403322, 39.920255 ],
        integral: "",
        is_region: 0,
        activity_id: "",
        TemplateArray: [],
        orderLocationObj: {
            positioning_success: 0,
            province: "",
            city: ""
        },
        isCueCoupon: !1,
        openCueCoupon: !1,
        getParams_status: !1,
        fromStock: "",
        show_recharge_mobile: "",
        recharge_tips: "",
        recharge_mobile: "",
        hasGoodOpenDF: !1,
        iscps: !1,
        cpstype: 2,
        cpsTxt: "",
        storeSearchBtn: {},
        service_fee: [],
        minDate: new Date().getTime(),
        installDateShow: !1,
        installDate: null,
        installDateText: "",
        install_comment: "",
        location: {},
        showLocation: !1,
        showInstallPop: !1,
        default_deduction: 0,
        showPage: !0,
        delivery_amount: 0,
        phone_bill_pro_goods: !1,
        clickMiniTemplate: !1,
        supp_point: {
            lng: "",
            lat: "",
            address: ""
        },
        recommend_goods: [],
        electricity_Guide: "",
        electricity: !1,
        eleUser: [],
        ele_no_showAdress: !1,
        sexSelect: "1",
        showArea: !1,
        use_wechat_address: !1,
        design_info: {
            cityName: "",
            countyName: "",
            detailInfo: "",
            provinceName: "",
            telNumber: "",
            userName: ""
        },
        ferightExplainPop: !1,
        freightExplain: {},
        o2odeliverName: "自提点",
        o2oSelfCarry: {},
        deliveryTimeShow: !1,
        costSpecShow: !1,
        selectCommunityShow: !1,
        serviceRegionShow: !1,
        cityDelivery: null,
        cityDelivery_community: {},
        cityDelivery_community_id: 0,
        cityDelivery_deliveryTime: {},
        yz_subscribe_disabled: !1,
        reserve_tel_name: "",
        reserve_mobile: "",
        reserve_order: null,
        reserve_obj_text: "预约人员",
        plugin_setting: "",
        camilo_resources_coupon_type: "",
        recharge_number: "",
        addressList_caller: "",
        oil_mobile: "",
        oil_account: "",
        oil_pre_id: "",
        consigneeName: "",
        consigneeMobile: "",
        reserveName: "",
        reservePhone: "",
        reserveDate: "",
        delivery_information: 0,
        address_codeEnable: !1,
        codeShow: !1,
        hideDispatch: !1,
        addressCodeClick: 0,
        orderShowIdCard: 0,
        orderShowDate: 0,
        idCard: "",
        customerName: "",
        customerPhoneNumber: "",
        memo: "",
        machineId: "",
        is_diy_form_jump: 0,
        cakeCity: "",
        cakeLat: "",
        cakeLng: "",
        cakeShipType: "",
        cakeShipDate: "",
        shipTimeText: "",
        shopDetail: "",
        shopName: "",
        shopId: "",
        deliveryDates: [],
        storeList: [],
        cakeCurrentTime: new Date().getTime(),
        cakeEndTime: "",
        cakeMoblie: "",
        cakeText: "",
        takeDates: [],
        cakeChecked: !1,
        cakeShow: !1,
        cakeTimeShow: !1,
        cakeStoreShow: !1,
        canTake: 0,
        canSame: 0,
        canShip: 0,
        deliveryArr: [],
        shopCakeArr: [],
        cakeDeliveryArr: [],
        show_add_address: !0
    },
    onLoad: function(t) {
        var e = this;
        wx.getStorage({
            key: "yz_basic_info",
            success: function(t) {
                var a = t.data;
                e.setData({
                    reserve_obj_text: a.lang.reserve_simple.reserve_obj || "预约人员",
                    vip_show: !!a.globalParameter.vip_show && a.globalParameter.vip_show,
                    address_codeEnable: !(!a.plugin_setting.address_code || !a.plugin_setting.address_code.enable),
                    hideDispatch: a.globalParameter.hide_dispatch || !1
                });
            }
        }), this.handleQueryData(t);
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
        var e = wx.getStorageSync("integral"), a = wx.getStorageSync("yz_basic_info") ? wx.getStorageSync("yz_basic_info").love : "";
        e && this.setData({
            integral: e,
            love_name: a
        });
        var i = wx.getStorageSync("yz_basic_info").plugin_setting || "";
        this.setData({
            plugin_setting: i
        });
    },
    onShow: function() {
        var t = this;
        this.data.submit_active = !0, this.setData({
            showPage: !0
        }), 10 == this.data.selected && this._getLocation(function(e) {
            var a = d.qqMapTransBMap(parseFloat(e.location.lng), parseFloat(e.location.lat));
            t.setData({
                "supp_point.lng": a.lng,
                "supp_point.lat": a.lat,
                "supp_point.address": e.address
            });
        });
    },
    tolocation: function() {
        wx.navigateTo({
            url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=suppligoodsOrde"
        });
    },
    setFreightExplainPop: function() {
        this.setData({
            ferightExplainPop: !this.data.ferightExplainPop
        });
    },
    getWxAdress: function() {
        var t = this;
        wx.chooseAddress({
            success: function(e) {
                var a = e;
                t.setData({
                    userAdress: "".concat(a.provinceName, " ").concat(a.cityName, " ").concat(a.countyName),
                    design_address: "".concat(a.detailInfo),
                    design_info: a
                }), t._requestByAddress();
            }
        });
    },
    handleQueryData: function(t) {
        var e = this;
        return i(a.default.mark(function i() {
            var s, o, r, n, c;
            return a.default.wrap(function(a) {
                for (;;) switch (a.prev = a.next) {
                  case 0:
                    return e.setData({
                        options: t
                    }), t.tag && e.setData({
                        _root_tag: t.tag
                    }), a.next = 4, e.checkAlbum("scope.userLocation");

                  case 4:
                    if (a.sent) {
                        a.next = 7;
                        break;
                    }
                    return a.abrupt("return", d.tips("获取位置失败，请重新进入后授权"));

                  case 7:
                    if (d.globalData.qqmapkey ? e.getCurrentOrderLocation() : d._getTemplate().then(function(t) {
                        e.getCurrentOrderLocation();
                    }), t.fromStock && "" != t.fromStock && e.setData({
                        fromStock: t.fromStock
                    }), t.iscps && e.setData({
                        _root_tag: "cps",
                        iscps: t.iscps
                    }), t.mobile && e.setData({
                        phone_bill_pro_goods: !0,
                        recharge_mobile: t.mobile
                    }), t.cpstype && e.setData({
                        cpstype: t.cpstype
                    }), t.activity_id && e.setData({
                        activity_id: t.activity_id
                    }), t.ind && e.setData({
                        ind: t.ind
                    }), t.reserve_order && e.setData({
                        reserve_order: JSON.parse(t.reserve_order)
                    }), s = !d._isTextEmpty(t.level_id), o = !d._isTextEmpty(t.team_id), e.setData({
                        isOpenTeam: s,
                        isJoinTeam: o
                    }), t.changeSelfCarry && (r = JSON.parse(t.changeSelfCarry), 12 == t.ind ? e.setData({
                        o2oSelfCarry: r
                    }) : e.setData({
                        defaultSelfCarry: r
                    })), e.setData({
                        _goodsId: t.goodsId || "",
                        _optionsId: t.optionsId || "",
                        _total: t.total || 1
                    }), "cake" !== t.tag) {
                        a.next = 34;
                        break;
                    }
                    return (n = wx.getStorageSync("cakeStoreDetail")) && (c = JSON.parse(n), e.setData({
                        shopId: c.shop_id,
                        shopName: c.shop_name,
                        shopDetail: c.address
                    })), e.setData({
                        cakeCity: t.city
                    }), console.log(e.data.cakeCity), e.handleBuy(), a.prev = 26, e._getLocation(function(t, a) {
                        e.setData({
                            cakeLat: a.lat,
                            cakeLng: a.lng
                        });
                    }), a.abrupt("return");

                  case 31:
                    a.prev = 31, a.t0 = a.catch(26), e.getRule();

                  case 34:
                    t.cart_ids && "undefined" != t.cart_ids && e.setData({
                        _cart_ids: t.cart_ids ? JSON.parse(t.cart_ids) : []
                    }), t.store_id && "undefined" != t.store_id && e.setData({
                        store_id: t.store_id
                    }), t.electricity && "electricity" == t.electricity && e.setData({
                        electricity: !0
                    }), t.oil_account && t.oil_mobile && e.setData({
                        oil_account: t.oil_account,
                        oil_mobile: t.oil_mobile
                    }), t.debtId && e.setData({
                        debtId: t.debtId
                    }), "machine" == t.tag && e.setData({
                        machineId: t.machineId
                    }), "POrder" != e.data._root_tag && "store" != e.data._root_tag ? e.getDispatchMethod() : e.handleBuy();

                  case 41:
                  case "end":
                    return a.stop();
                }
            }, i, null, [ [ 26, 31 ] ]);
        }))();
    },
    getDispatchMethod: function(t) {
        var e = this;
        if ("cake" != this.options.tag) {
            if ("communityBuy" == this.data._root_tag) {
                return this.setData({
                    dispatch: [ {
                        dispatch_type_id: 8,
                        name: "自提点"
                    } ],
                    selected: 8
                }), void this.handleBuy();
            }
            var a = {
                goods_id: this.data._goodsId ? this.data._goodsId.toString() : "",
                cart_ids: this.data._cart_ids.toString() || t,
                store_id: this.data.options.store_id || this.data.options.groupStoreID,
                model: ""
            };
            if ("store" == this.data._root_tag && (a.model = "store"), "-10" == this.data._root_tag && (a.model = "packFixedPrice"), 
            "warehouse" == this.data._root_tag) {
                var i = [];
                JSON.parse(this.options.goodCollection).forEach(function(t) {
                    i.push(t.goods_id);
                }), a.goods_ids = JSON.stringify(i);
            }
            (this.data.isOpenTeam || this.data.isJoinTeam) && (a.nonsupport = [ "15" ]);
            var s = d.getNetAddresss("memberCart.dispatch-type.index");
            "exchange_code" == this.data._root_tag && (s = d.getNetAddresss("plugin.exchange-code.api.dispatch.index"), 
            a = {
                goods_ids: this.data._goodsId ? this.data._goodsId.toString() : ""
            }), d._postNetWork({
                url: s,
                data: a,
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? (d._isTextEmpty(e.data.debtId) ? (e.setData({
                        dispatch: a.data,
                        selected: a.data && a.data.length > 0 ? a.data[0].dispatch_type_id : 0
                    }), 11 == e.data.selected && e.getDeliverySetting(), e.data.dispatch.forEach(function(t, a) {
                        8 == t.dispatch_type_id ? (console.log("有自提点配送方式，请求定位获取自提点列表"), e.data.ind && e.setData({
                            selected: e.data.ind,
                            selectedMode: a,
                            ind: !1
                        })) : 12 == t.dispatch_type_id && 12 == e.data.ind && e.data.o2oSelfCarry && e.data.o2oSelfCarry.id && e.setData({
                            selected: 12,
                            selectedMode: a
                        });
                    })) : e.setData({
                        dispatch: [ {
                            dispatch_type_id: 1,
                            name: "快递"
                        } ],
                        selected: a.data && a.data.length > 0 ? a.data[0].dispatch_type_id : 0
                    }), "store" == e.data._root_tag ? e._getStoreCartBuy(e.data.storeCarts) : e.handleBuy()) : wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1e3
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else this.handleBuy();
    },
    handleBuy: function(t) {
        switch (this.data._root_tag) {
          case this.data.TAG_ACTION_BUY:
          case "appointment_goods":
          case "yun_sign_goods":
          case "yunqian_api":
          case "cps":
          case "starGroup":
          case "blindBox":
          case "fromExchange":
          case "newRetail":
          case "auction":
          case "zhpGroup":
          case "o2oDeposit":
            if (t) {
                if ("fromExchange" == this.data._root_tag && "2" === t) return void this._getDataActionBuy(0);
            } else this.data.options.store_id ? this._initStore("is_activity") : this.data.options.groupStoreID && 0 != this.data.options.groupStoreID && "undefined" != this.data.options.groupStoreID && this._initStore();
            this._getDataActionBuy();
            break;

          case this.data.TAG_ACTION_CART:
          case "packagBuy":
          case "-10":
          case "communityBuy":
            this.data.isCartsOrder = !0, this._getDataActionCart();
            break;

          case "store":
            this.data.isCartsOrder = !0, t ? this._getDataActionStoreCart() : 1 == this.data.options.isCash ? this.getCashGood() : this._initStore();
            break;

          case "rentCartBuy":
          case "rentBuy":
            t ? this._rentGoodBuy() : (this.setData({
                currentIndex: "999",
                isRent: !0
            }), this._getRentDataActionCart([], []), this._getRentTimeList(), this._judgeIsRight());
            break;

          case "POrder":
            this.getPendingOrder_type();
            break;

          default:
            this._getDataActionBuy();
        }
    },
    reserInp: function(t) {
        var a = t.currentTarget.dataset.key, i = t.detail;
        this.setData(e({}, a, i));
    },
    handleDataActionBuyUrl: function(t, e) {
        if (this.data.isRent) this.data.order_url = "plugin.lease-toy.api.order.create"; else if (1 == this.data.fromStock || 2 == this.data.fromStock) {
            this.data.pre_order_url = d.getNetAddresss("plugin.agency.api.goods-buy.index"), 
            this.data.order_url = "plugin.agency.api.create.index";
            var a = this.selectComponent("#agencySaleman");
            2 == this.data.fromStock && (this.data.order_other_json = {
                is_retail: !0,
                salesman_uid: a && a.data.self_member_id || ""
            });
        } else if (this.data.isOpenTeam || this.data.isJoinTeam) {
            this.data.order_other_json = {
                option_level_id: this.options.option_level_id
            };
            var i = "fight-groups";
            this.options.plu && "ywm" == this.options.plu && (i = "ywm-fight-groups"), this.data.isOpenTeam ? (this.data.order_other_json.level_id = this.options.level_id, 
            this.data.pre_order_url = "plugin.".concat(i, ".frontend.controllers.team.pre-open-team")) : this.data.isJoinTeam && (this.data.order_other_json.team_id = this.options.team_id, 
            this.data.pre_order_url = "plugin.".concat(i, ".frontend.controllers.team.pre-join-team")), 
            this.data.order_url = "plugin.".concat(i, ".frontend.controllers.create.index"), 
            this.options.groupStoreID && 0 != this.options.groupStoreID && "undefined" != this.options.groupStoreID && (this.data.order_other_json.store_id = this.options.groupStoreID, 
            this.data.pre_order_url = this.data.isOpenTeam ? "plugin.fight-groups.frontend.store.frontend-team.pre-open-team" : "plugin.fight-groups.frontend.store.frontend-team.pre-join-team", 
            this.data.order_url = "plugin.fight-groups.frontend.store.create.index");
        } else if ("appointment_goods" == this.options.tag) this.data.order_url = "plugin.appointment.frontend.order.create", 
        this.data.options.exchange_code_id && (this.data.order_other_json = {
            exchange_code_id: this.data.options.exchange_code_id
        }, this.data.pre_order_url = "plugin.exchange-code.api.goods-buy"); else if ("groupBuy_open" == this.options.type || "groupBuy_join" == this.options.type) this.data.order_other_json = {
            at_id: this.options.at_id,
            leader_id: this.options.leader_id || 0
        }, delete t.option_id, this.data.pre_order_url = "groupBuy_open" == this.options.type ? "plugin.together-purchase.api.team.preOpenTeam" : "plugin.together-purchase.api.team.preJoinTeam", 
        this.data.order_url = "plugin.together-purchase.api.create.index"; else if ("grabGroup_open" == this.options.type || "grabGroup_join" == this.options.type) this.data.order_other_json = {
            at_id: this.options.at_id,
            leader_id: this.options.leader_id || 0,
            snatch_option_id: this.data._optionsId
        }, t.option_id = 0, this.data.pre_order_url = "grabGroup_open" == this.options.type ? "plugin.snatch-regiment.api.team.preOpenTeam" : "plugin.snatch-regiment.api.team.preJoinTeam", 
        this.data.order_url = "plugin.snatch-regiment.api.create.index"; else if ("POrder" == this.data._root_tag) this.data.order_other_json = {
            pending_order_type: this.data.selected
        }, this.data.pre_order_url = "plugin.pending-order.frontend.goods-buy.index", this.data.order_url = "plugin.pending-order.frontend.create.index"; else if ("o2oDeposit" == this.data._root_tag) this.data.order_other_json = {
            store_id: this.options.store_id || 0
        }, this.data.pre_order_url = "plugin.deposit-ladder.frontend.store.activity-buy"; else if (this.options.store_id) "reserve" == this.data._root_tag ? (this.data.order_other_json = {
            date_id: this.options.date_id,
            store_id: this.options.store_id,
            goods_id: this.options.goodsId
        }, "order" == e && (this.data.order_other_json.date_id = this.options.date_id, this.data.order_other_json.mobile = this.data.reservePhone, 
        this.data.order_other_json.realname = this.data.reserveName), this.data.pre_order_url = "plugin.store-reserve.frontend.GoodsBuy.index", 
        this.data.order_url = "plugin.store-reserve.frontend.create.index") : (this.data.order_other_json = {
            store_id: this.options.store_id || 0
        }, "order" === e && (this.data.order_other_json.mobile = this.data.linkinfo.mobile, 
        this.data.order_other_json.realname = this.data.linkinfo.name, this.data.order_other_json.cart_ids = []), 
        this.data.pre_order_url = "plugin.store-cashier.frontend.store.goods-buy"); else if ("blindBox" == this.data._root_tag) this.data.order_other_json = {
            activity_id: this.data.activity_id,
            goods_id: this.data._goodsId
        }, this.data.pre_order_url = "plugin.blind-box.api.buy", this.data.order_url = "plugin.blind-box.api.create"; else if ("fromExchange" == this.data._root_tag) this.options.store_id && "undefined" != this.options.store_id ? (this.data.order_other_json.store_id = this.options.store_id, 
        this.data.pre_order_url = "plugin.store-cashier.frontend.store.exchange-center") : this.data.pre_order_url = "coupon.exchange-center.exchange-buy"; else if ("newRetail" == this.options.tag) this.data.order_other_json = {
            retail_state: Number(this.options.retailState),
            level_id: Number(this.options.NRLevelId) || 0,
            sales_id: Number(this.options.sales_id) || 0
        }, this.data.pre_order_url = this.newRetailApi(this.options.retailState), 0 == Number(this.options.retailState) ? this.data.order_url = "plugin.new-retail.frontend.create.ordinary" : this.data.order_url = "plugin.new-retail.frontend.create.index"; else if ("auction" == this.data._root_tag) this.data.order_other_json = {
            fixed_price: this.data.options.fixed_price,
            auction_sn: this.data.options.auction_sn
        }, this.data.pre_order_url = "plugin.auction.api.goods-buy", this.data.order_url = "plugin.auction.api.order-create"; else if ("zhpGroup" == this.data._root_tag) this.data.pre_order_url = "plugin.zhp-group-lottery.frontend.goods.get-goods-Info", 
        t.option_id = this.data._optionsId ? this.data._optionsId : "0", this.data.order_other_json = {
            activity_id: this.data.activity_id
        }, this.data.order_url = "plugin.zhp-group-lottery.frontend.order.index"; else if ("groupWork" == this.data._root_tag) this.data.order_other_json = {
            alliance_detail_id: this.data.options.alliance_detail_id,
            activity_option_id: this.data.options.activity_option_id
        }, this.data.pre_order_url = "plugin.group-work.frontend.modules.order.controllers.buy.index", 
        this.data.order_url = "plugin.group-work.frontend.modules.order.controllers.create.index"; else if ("warehouse" == this.data._root_tag) this.data.order_other_json = {
            goods: this.options.goodCollection
        }, this.data.pre_order_url = "plugin.warehouse.frontend.controllers.takeDelivery.goods-buy", 
        this.data.order_url = "plugin.warehouse.frontend.controllers.takeDelivery.order-create"; else if (d._isTextEmpty(this.data.debtId)) {
            if ("sign_buy" == this.options.tag) this.data.order_other_json = {
                goods: JSON.parse(this.data.options.goods),
                package_id: this.data.options.package_id
            }, this.data.pre_order_url = "plugin.sign-buy.frontend.package.pre-buy", this.data.order_url = "plugin.sign-buy.frontend.package.buy"; else if ("tourAround" == this.options.tag) this.data.order_url = "plugin.travel-around.frontend.order.createOrder"; else if ("stock_service" == this.options.tag) this.data.order_other_json = {
                take_way: this.data.options.take_way,
                stock_token: this.data.options.stock_token,
                take_type: this.data.options.take_type,
                goods: '[{"goods_id":'.concat(this.data.options.goodsId, ',"total":').concat(this.data.options.total, ',"option_id":').concat(this.data.options.option_id, "}]")
            }, this.data.pre_order_url = "plugin.stock-service.frontend.controllers.goods-buy", 
            this.data.order_url = "plugin.stock-service.frontend.controllers.order-create"; else if ("machine" == this.data._root_tag) this.data.order_other_json.automat_machine_id = this.data.machineId, 
            this.data.pre_order_url = "plugin.automat.frontend.goods-buy.index", this.data.order_url = "plugin.automat.frontend.create.index", 
            this.setData({
                hideDispatch: !0
            }); else if ("cake" === this.options.tag) this.data.order_other_json = {
                city_cake: this.data.cakeCity
            }; else if ("exchange_code" == this.options.tag) {
                var s = JSON.parse(this.data.options.goods), o = 0;
                s.forEach(function(t) {
                    o += t.total;
                }), this.data.order_other_json = {
                    goods: JSON.stringify(s),
                    total: o,
                    exchange_code_id: this.data.options.exchange_code_id
                }, this.data.pre_order_url = "plugin.exchange-code.api.cart.index", this.data.order_url = "plugin.exchange-code.api.create";
            }
        } else this.data.order_other_json = {
            debtor_id: this.data.options.debtId
        }, this.data.pre_order_url = "plugin.debt-shop.frontend.goods-buy", this.data.order_url = "plugin.debt-shop.frontend.create";
        if (null != this.data.reserve_order) {
            this.data.order_url = "plugin.reserve-simple.frontend.order.create";
            var r = this.data.reserve_order, n = r.service_id, c = r.obj_id, h = r.begin_time, _ = this.data.reserve_tel_name, l = this.data.reserve_mobile;
            t.reserve_order = {
                service_id: n,
                obj_id: c,
                begin_time: h,
                customer_name: _,
                customer_tel: l
            }, t.dispatch_type_id = 0;
        }
        if ("electricity" == this.options.electricity && (this.data.order_other_json.account_id = this.options.account_id), 
        this.data.pre_order_url || (this.data.pre_order_url = "order.goods-buy", this.data.options.exchange_code_id && (this.data.order_url = "plugin.yz-supply-camilo-resources.frontend.order.create.index", 
        this.data.order_other_json = {
            exchange_code_id: this.data.options.exchange_code_id
        })), this.data.order_url || (this.data.iscps ? this.data.order_url = "plugin.aggregation-cps.api.create-order" : this.data.order_url = "order.create"), 
        this.options.merchant_meeting && (this.data.order_other_json.merchant_meeting = this.options.merchant_meeting), 
        0 != this.data.default_deduction && (t.no_deduction_ids = this.data.default_deduction), 
        this.data.cityDelivery && 1 == this.data.cityDelivery.future_state && this.data.cityDelivery_deliveryTime.start_time && this.data.cityDelivery_deliveryTime.end_time && (t.expect_start_time = this.data.cityDelivery_deliveryTime.start_time, 
        t.expect_end_time = this.data.cityDelivery_deliveryTime.end_time), this.data.use_wechat_address && (1 == this.data.selected || 0 == this.data.selected)) {
            var u = {
                address: this.data.design_address || "",
                city: this.data.design_info.cityName,
                district: this.data.design_info.countyName,
                id: "",
                isdefault: "",
                latitude: "",
                longitude: "",
                mobile: this.data.design_info.telNumber,
                province: this.data.design_info.provinceName,
                street: "",
                uid: "",
                uniacid: "",
                username: this.data.design_info.userName,
                zipcode: ""
            };
            t.address = u.address ? encodeURIComponent(JSON.stringify(u)) : [];
        }
        return "newBlindBox" == this.options.name && (console.log(this.options, 111111), 
        this.data.order_other_json = {
            new_blind_box: {
                select_goods: JSON.parse(this.options.select_goods),
                activity_id: this.options.activity_id
            }
        }), Object.assign(t, this.data.order_other_json);
    },
    handleDataActionCartUrl: function(t, e) {
        if ("communityBuy" == this.data._root_tag ? (this.data.pre_order_url = "plugin.package-deliver.frontend.cartBuy.index", 
        this.data.order_other_json = {
            dispatch_type_id: 8,
            package_deliver_id: this.options.package_deliver_id,
            group_id: this.options.group_id
        }, this.data.order_url = "plugin.package-deliver.frontend.create.index") : "-10" == this.data._root_tag && (this.data.pre_order_url = "plugin.pack-fixed-price.api.cart-buy.index", 
        "order" === e && (this.data.order_other_json.cart_ids = JSON.stringify(this.data._cart_ids)), 
        this.data.order_url = "plugin.pack-fixed-price.api.create.index"), "packagBuy" == this.data._root_tag) {
            var a = JSON.parse(this.data.options.packagJson);
            this.data.order_other_json = {
                package_id: a.package_id,
                goods: JSON.stringify(a.goods_list)
            }, this.data.pre_order_url = "plugin.goods-package.frontend.package.package-buy.index";
        }
        return "order" === e && "-10" != this.data._root_tag && "packagBuy" != this.data._root_tag && (this.data.order_other_json.cart_ids = JSON.stringify(this.data._cart_ids)), 
        this.data.pre_order_url || (this.data.pre_order_url = "order.cart-buy"), this.data.order_url || (this.data.order_url = "order.create", 
        this.data.options.exchange_code_id && (this.data.order_other_json = {
            exchange_code_id: this.data.options.exchange_code_id
        }, this.data.pre_order_url = "plugin.exchange-code.api.goods-buy")), 0 != this.data.default_deduction && (t.no_deduction_ids = this.data.default_deduction), 
        Object.assign(t, this.data.order_other_json);
    },
    newRetailApi: function(t) {
        var e = Number(t);
        return 0 == e ? "plugin.new-retail.frontend.order.ordinaryPay" : 1 == e ? "plugin.new-retail.frontend.order.purchaseRetailGoods" : 2 == e ? "plugin.new-retail.frontend.order.freeSend" : 3 == e ? "plugin.new-retail.frontend.order.retailCodePay" : 4 == e ? "plugin.new-retail.frontend.order.purchaseStock" : 5 == e ? "plugin.new-retail.frontend.order.retailCodePay" : void 0;
    },
    setPopShow: function(t) {
        var a = t.currentTarget.dataset.name;
        this.setData(e({}, a, !this.data[a]));
    },
    onCakeChange: function(t) {
        this.data.address ? t.detail ? this.setData({
            cakeMoblie: this.data.mobile,
            cakeChecked: t.detail
        }) : this.setData({
            cakeMoblie: "",
            cakeChecked: t.detail
        }) : (0, s.default)("请先选择地址");
    },
    deliveryChange: function(t) {
        console.log(t), this.setData({
            cakeShipType: t.detail
        }), "shop" === t.detail ? this.data.deliveryDates = this.data.shopCakeArr : this.data.deliveryDates = this.data.deliveryArr, 
        console.log(this.data.shopCakeArr);
        var e = this.data.deliveryDates;
        if (e.length > 0) {
            var a, i, s = null === (a = e[0]) || void 0 === a ? void 0 : a.date, o = null === (i = e[e.length - 1]) || void 0 === i ? void 0 : i.date, r = new Date(s).getTime(), d = new Date(o).getTime();
            this.setData({
                cakeCurrentTime: r,
                cakeEndTime: d,
                deliveryDates: this.data.deliveryDates
            });
        }
    },
    onCakeInput: function(t) {
        this.setData({
            cakeMoblie: t.detail
        });
    },
    cakePopup: function(t) {
        var a = t.currentTarget.dataset.name;
        this.data.deliveryDates.length > 0 ? this.setData(e({}, a, !0)) : (0, s.default)("没有配送日期");
    },
    cakeTimePopup: function(t) {
        var a = t.currentTarget.dataset.name;
        this.data.cakeShipDate ? this.setData(e({}, a, !0)) : (0, s.default)("请先选择配送日期");
    },
    deliveryCancel: function(t) {
        var a = t.currentTarget.dataset.name;
        this.setData(e({}, a, !1));
    },
    deliveryConfirm: function(t) {
        var e = t.detail, a = this.timestampToTime(e), i = new Date(new Date(a).toLocaleDateString()).getTime(), s = this.data.deliveryDates.find(function(t) {
            var e = new Date(new Date(t.date).toLocaleDateString()).getTime();
            return i === e;
        }), o = [];
        o = "delivery" === this.data.cakeShipType ? s.validate_delivery_times : s.validate_take_times;
        var r = [];
        for (var d in o) r.push({
            text: o[d],
            checked: !1
        });
        this.setData({
            cakeShipDate: a,
            cakeShow: !1,
            takeDates: r
        });
    },
    cakeTimeChange: function(t) {
        var e = t.currentTarget.dataset, a = e.text, i = e.index, s = this.data.takeDates;
        for (var o in s) s[o].checked = !1;
        s[i].checked = !s[i].checked, this.setData({
            takeDates: s,
            cakeText: a
        });
    },
    cakeTimeConfirm: function() {
        this.setData({
            cakeTimeShow: !1,
            shipTimeText: this.data.cakeText
        });
    },
    timestampToTime: function(t) {
        if (t) {
            var e = new Date(Number(t));
            return e.getFullYear() + "-" + ((e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1) + "-") + (this.change(e.getDate()) + " ");
        }
    },
    change: function(t) {
        return t < 10 ? "0" + t : t;
    },
    setInstallDateShow: function() {
        this.setData({
            installDateShow: !this.data.installDateShow
        });
    },
    gotochangeCake: function() {
        this.setData({
            cakeStoreShow: !0
        });
    },
    showDetail: function(t) {
        var e = t.currentTarget.dataset.item, a = JSON.stringify(e);
        e && wx.setStorageSync("cakeStoreDetail", a), this.setData({
            cakeStoreShow: !1,
            shopId: e.shop_id,
            shopName: e.shop_name,
            shopDetail: e.address
        });
    },
    getRule: function() {
        var t = this, e = {
            city: this.data.cakeCity,
            goods_id: this.data._goodsId,
            lng: this.data.cakeLng,
            lat: this.data.cakeLat
        }, a = d.getNetAddresss("plugin.yz-supply-cake.frontend.index.index.getStore");
        d._getNetWork({
            url: a,
            data: e,
            success: function(e) {
                var a = e.data;
                if (1 == a.result) {
                    var i = a.data;
                    t.setData({
                        storeList: i
                    });
                } else wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    cakeData: function(t) {
        var e, a, i, s = this, o = null == t || null === (e = t.data) || void 0 === e || null === (a = e.orders[0]) || void 0 === a || null === (i = a.yz_supply_cake_distribution_rule) || void 0 === i ? void 0 : i.data;
        if (o) {
            var r, d, n = [], c = "".cakeShipDate, h = "".shipTimeText, _ = "";
            "1" === o.can_same && (n.push({
                dispatch_type_id: "same",
                name: "快递"
            }), c = !1, h = o.delivery_text), "1" === o.can_ship && n.push({
                dispatch_type_id: "delivery",
                name: "商家配送"
            }), "1" === o.can_take && n.push({
                dispatch_type_id: "shop",
                name: "门店自提"
            }), this.setData({
                cakeDeliveryArr: n
            }), this.data.cakeDeliveryArr.forEach(function(t, e) {
                e === s.data.selectedMode && (_ = t.dispatch_type_id);
            });
            var l = [];
            "delivery" === _ ? (l = o.validate_delivery_dates, this.setData({
                deliveryArr: l
            })) : l = o.validate_take_dates, this.setData({
                shopCakeArr: o.validate_take_dates
            });
            var u = null === (r = l[0]) || void 0 === r ? void 0 : r.date, p = null === (d = l[l.length - 1]) || void 0 === d ? void 0 : d.date, g = new Date(u).getTime(), f = new Date(p).getTime();
            this.setData({
                deliveryDates: l,
                canSame: o.can_same,
                canTake: o.can_take,
                canShip: o.can_ship,
                cakeShipType: _,
                shipTimeText: h,
                cakeShipDate: c,
                cakeCurrentTime: g,
                cakeEndTime: f
            });
        }
    },
    bindInstallDateChange: function(t) {
        this.setInstallDateShow();
        var e = t.detail;
        this.setData({
            installDate: parseInt(e / 1e3),
            installDateText: o.default.formatTime(new Date(e))
        });
    },
    showDeliveryMap: function() {
        this.setData({
            deliveryScopeShow: !0
        });
    },
    showLocationPop: function() {
        this.setData({
            showInstallPop: !this.data.showInstallPop
        });
    },
    deliveryScopeShowClose: function() {
        this.setData({
            deliveryScopeShow: !1
        });
    },
    confirmLocation: function(t) {
        this.setData({
            "location.latitude": t.detail.lat,
            "location.longitude": t.detail.lng,
            "location.address": t.detail.address
        }), this.showLocationPop();
    },
    _checkTaxGoods: function(t) {
        t && t.status ? (this.setData({
            showMyinfo: t.status
        }), this.data.isTaxGoods = !0) : (this.data.isTaxGoods = !1, this.setData({
            showMyinfo: !1
        }));
    },
    _getMemberInfo: function(t) {
        this.setData({
            myRealname: t.realname,
            myIdcard: t.idcard
        });
    },
    alertMyInfo: function() {
        this.setData({
            showFrom: !0
        });
    },
    confirmFrom: function(t) {
        this.setData({
            myRealname: t.detail.name,
            myIdcard: t.detail.card,
            showFrom: t.detail.status
        });
    },
    gotochangeSelfCarry: function() {
        var t = {
            distributionUserName: this.data.linkinfo.name ? this.data.linkinfo.name : "",
            distributionUserMobile: this.data.linkinfo.mobile ? this.data.linkinfo.mobile : ""
        };
        try {
            wx.setStorageSync("selfCarryInfo", JSON.stringify(t));
        } catch (t) {
            console.log(t);
        }
        var e = "/packageC/selfCarry/selfCarry_info/selfCarry_info?tag=" + this.data.options.tag + "&goodsId=" + this.data.options.goodsId + "&optionsId=" + this.data.options.optionsId + "&total=" + this.data.options.total + "&goods=" + JSON.stringify(this._assembleGoods()) + "&ind=" + this.data.selected;
        this.data.options.cart_ids && (e = e + "&cart_ids=" + this.data.options.cart_ids), 
        this.data.isOpenTeam ? (e = e + "&level_id=" + this.options.level_id + "&option_level_id=" + this.options.option_level_id, 
        this.options.plu && "ywm" == this.options.plu && (e += "&plu=ywm")) : this.data.isJoinTeam && (e = e + "&team_id=" + this.options.team_id + "&option_level_id=" + this.options.option_level_id, 
        this.options.plu && "ywm" == this.options.plu && (e += "&plu=ywm")), "warehouse" == this.data._root_tag && (e = e + "&goodCollection=" + this.options.goodCollection), 
        this.options.store_id && (e = e + "&store_id=" + this.options.store_id), this.options.groupStoreID && Number(this.options.groupStoreID) > 0 && (e = e + "&groupStoreID=" + this.options.groupStoreID), 
        this.options.exchangeData && (e = e + "&exchangeData=" + this.options.exchangeData), 
        wx.redirectTo({
            url: e
        });
    },
    setDispatch: function(t) {
        var e = this, a = t.detail.title;
        if ("cake" === this.options.tag) {
            var i = "";
            this.data.dispatch.forEach(function(t) {
                t.name == a && (i = t.dispatch_type_id);
            }), this.setData({
                cakeShipDate: "",
                shipTimeText: "",
                cakeShipType: i
            });
        }
        this.data.dispatch.forEach(function(i) {
            i.name == a && e.setData({
                selected: i.dispatch_type_id,
                selectedMode: t.detail.index
            });
        }), 10 == this.data.selected && this._getLocation(function(t) {
            var a = d.qqMapTransBMap(parseFloat(t.location.lng), parseFloat(t.location.lat));
            e.setData({
                "supp_point.lng": a.lng,
                "supp_point.lat": a.lat,
                "supp_point.address": t.address
            });
        }), "11" == this.data.selected ? this.getDeliverySetting() : this._requestByAddress();
    },
    getDeliverySetting: function() {
        var t = this;
        if (null == this.data.cityDelivery) {
            var e = d.getNetAddresss("plugin.city-delivery.frontend.order.getDeliverySetting");
            d._postNetWork({
                url: e,
                success: function(e) {
                    var a = e.data;
                    if (1 == a.result) {
                        var i = {};
                        i.cityDelivery = a.data, a.data.fence_setting && (i["markers_2[0].longitude"] = a.data.fence_setting.store_longitude, 
                        i["markers_2[0].latitude"] = a.data.fence_setting.store_latitude, i["delivery.longitude"] = a.data.fence_setting.store_longitude, 
                        i["delivery.latitude"] = a.data.fence_setting.store_latitude, a.data.fence_setting.delivery_area && (i["polygons_2[0].points"] = a.data.fence_setting.delivery_area.map(function(t) {
                            var e = {};
                            return e.longitude = t[0], e.latitude = t[1], e;
                        }))), i.need_lat = 1, t.data.order_data && t.data.order_data.forEach(function(t) {
                            1 * a.data.min_amount > 1 * t.goods_price && (i.yz_subscribe_disabled = !0);
                        }), t.setData(i), t.selectComponent(".deliveryTime").setListData(a.data.time_setting, a.data.default_choose), 
                        a.data.default_choose || t._requestByAddress();
                    }
                }
            });
        } else this._requestByAddress();
    },
    _getDataActionBuy: function(t) {
        var e = this;
        console.log(t);
        var a = this, i = {
            goods_id: this.data._goodsId,
            total: this.data._total,
            option_id: this.data._optionsId || "0",
            member_coupon_ids: this._assembleCoupons(),
            orders: JSON.stringify(this._assembleDeduction()),
            address: encodeURIComponent(JSON.stringify(this.data.currentAddress)),
            dispatch_type_id: this.data.selected,
            mark: this.data.options.mark ? this.data.options.mark : 0
        };
        8 == this.data.selected && (i.package_deliver_id = this.data.defaultSelfCarry.id), 
        12 == this.data.selected && (i.package_deliver_id = this.data.o2oSelfCarry.id), 
        "fromExchange" == this.data._root_tag && (i.data = JSON.parse(this.data.options.exchangeData), 
        i.is_exchange = 0 == t ? 0 : 1), "newRetail" == this.options.tag && 2 == this.options.retailState && (i.goods = JSON.parse(this.options.goods) || []), 
        i = this.handleDataActionBuyUrl(i);
        var s = d.getNetAddresss(this.data.pre_order_url);
        wx.showLoading({
            title: "加载中",
            icon: "none",
            duration: 1500
        }), 0 == this.data.clicktag && (this.setData({
            clicktag: 1
        }), d._postNetWork({
            url: s,
            data: i,
            success: function(t) {
                var i = t.data;
                if (1 == i.result) {
                    if ("reserve" == a.options.tag && (i.data.reserve_date && e.setData({
                        reserveDate: i.data.reserve_date.date
                    }), i.data.reserve_deduction && e.setData({
                        reserve_deduction: i.data.reserve_deduction
                    }), i.data.reserve_deduction_love && e.setData({
                        reserve_deduction_love: i.data.reserve_deduction_love
                    }), "tourAround" == a.options.tag)) {
                        var s, o = response.data;
                        e.setData({
                            orderShowIdCard: null === (s = o.data.orders[0]) || void 0 === s ? void 0 : s.travel_around_order.orderShowIdCard
                        });
                    }
                    if ("cake" == a.options.tag) {
                        var r = t.data;
                        e.cakeData(r);
                    }
                    "groupBuy_open" != a.options.type && "groupBuy_join" != a.options.type || a.setData({
                        isGetAgreementPay: !0,
                        AgreementPay: a.data.goodsInfo.together_purchase_agreement ? a.data.goodsInfo.together_purchase_agreement : ""
                    }), a.setData({
                        goodsInfo: i.data,
                        cup_notice: !0,
                        diyShow: !1
                    }), a._setViewData(i.data), "fromExchange" == e.data._root_tag ? a.defaultSelectCoupon(i.data.discount.member_coupons) : i.data.discount && a._initCoupon(i.data.discount), 
                    e.data.codeShow && e.submitBtnPost();
                } else wx.showModal({
                    title: "提示",
                    content: i.msg,
                    success: function(t) {
                        if (t.confirm) {
                            if ("404" == i.data.address_error) return void wx.navigateTo({
                                url: "/packageD/member/addressList/addressList"
                            });
                            try {
                                var e = wx.getStorageSync("orderErrReturnUrl");
                                e ? wx.redirectTo({
                                    url: e
                                }) : wx.navigateBack({
                                    delta: 1
                                });
                            } catch (t) {
                                wx.navigateBack({
                                    delta: 1
                                });
                            }
                        } else t.cancel && wx.navigateBack({
                            delta: 1
                        });
                    }
                });
                setTimeout(function() {
                    a.setData({
                        cup_notice: !0,
                        clicktag: 0
                    }), console.log("执行结束"), wx.hideLoading();
                }, 1e3);
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    },
    _getDataActionCart: function() {
        var t = this, e = this, a = {
            cart_ids: this.data._cart_ids.toString(),
            member_coupon_ids: this._assembleCoupons(),
            orders: JSON.stringify(this._assembleDeduction()),
            address: encodeURIComponent(JSON.stringify(this.data.currentAddress)),
            dispatch_type_id: this.data.selected
        };
        8 == this.data.selected && (a.package_deliver_id = this.data.defaultSelfCarry.id), 
        12 == this.data.selected && (a.package_deliver_id = this.data.o2oSelfCarry.id), 
        this.data.order_other_json = {}, a = this.handleDataActionCartUrl(a);
        var i = d.getNetAddresss(this.data.pre_order_url);
        d._getNetWork({
            url: i,
            data: a,
            success: function(a) {
                var i = a.data;
                1 == i.result ? (e.setData({
                    goodsInfo: i.data,
                    cup_notice: !0,
                    diyShow: !1
                }), e._initCoupon(i.data.discount), e._setViewData(i.data), t.data.codeShow && t.submitBtnPost()) : (e.setData({
                    cup_notice: !0
                }), (0, s.default)(i.msg), wx.showModal({
                    title: "提示",
                    content: i.msg,
                    showCancel: !1,
                    success: function(t) {
                        wx.navigateBack({
                            delta: 1
                        });
                    }
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _initStore: function(t) {
        var e = this;
        this.setData({
            recipient_name: "",
            recipient_mobile: ""
        });
        var a = this.options.groupStoreID && "undefined" != this.options.groupStoreID ? this.options.groupStoreID : this.data.store_id, i = d.getNetAddresss("plugin.store-cashier.frontend.store.get-store-info.get-info-by-store-id");
        i += "&store_id=" + a, d._getNetWork({
            url: i,
            success: function(a) {
                var i = a.data;
                if (1 == i.result) {
                    if (e.setData({
                        store_info: i.data,
                        recipient_name: i.data.store_carry.name,
                        recipient_mobile: i.data.store_carry.number
                    }), "is_activity" === t || e.options.groupStoreID || e._getDataActionStoreCart(), 
                    i.data.store_delivery && i.data.store_delivery.delivery_status || 1 == i.data.need_lat) {
                        e.setData({
                            need_lat: i.data.need_lat,
                            delivery_status: i.data.store_delivery.delivery_status,
                            delivery_note: i.data.store_delivery ? i.data.store_delivery.delivery_note : "",
                            delivery_amount: i.data.store_delivery ? i.data.store_delivery.delivery_amount : 0
                        });
                        var o = i.data.store_delivery && "" != i.data.store_delivery.delivery_area ? i.data.store_delivery.delivery_area : [], r = i.data.store_delivery ? i.data.store_delivery.locations : {}, d = [];
                        if (o.forEach(function(t, e) {
                            d.push([ Number(t.R), Number(t.Q) ]);
                        }), e.setData({
                            delivery_area: d,
                            locations: [ Number(r.longitude).toFixed(6), Number(r.latitude).toFixed(6) ]
                        }), e.data.locations && e.data.locations.length > 0 && e.setData({
                            "markers_2[0].longitude": e.data.locations[0],
                            "markers_2[0].latitude": e.data.locations[1],
                            "delivery.longitude": e.data.locations[0],
                            "delivery.latitude": e.data.locations[1]
                        }), e.data.delivery_area && e.data.delivery_area.length > 0) {
                            for (var n = [], c = 0; c < e.data.delivery_area.length; c++) n.push({
                                longitude: e.data.delivery_area[c][0],
                                latitude: e.data.delivery_area[c][1]
                            });
                            e.setData({
                                "polygons_2[0].points": n
                            });
                        }
                    }
                } else (0, s.default)(i.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getCashGood: function() {
        var t = d.getNetAddresss("plugin.store-cashier.frontend.store.enter.getSetGoodsId"), e = this;
        d._getNetWork({
            url: t,
            data: {},
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    goods_id: a.data.goods_id
                }), a.data.store ? (e.setData({
                    _root_tag: "store",
                    store_info: a.data.store,
                    store_id: a.data.store.id || a.data.store.store_id
                }), e._getDataActionStoreCart()) : (e.setData({
                    _root_tag: "-2",
                    _goodsId: a.data.goods_id,
                    store_id: 0
                }), e._getDataActionBuy())) : (0, s.default)(a.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _getDataActionStoreCart: function() {
        var t = this;
        if (this.data.store_id) {
            if (this.data.storeCarts.length > 0) return this.setData({
                cup_notice: !0
            }), void this._getStoreCartBuy(this.data.storeCarts);
            var e = this, a = d.getNetAddresss("plugin.store-cashier.frontend.shoppingCart.member-cart.index");
            a += "&store_id=" + this.data.store_id, d._getNetWork({
                url: a,
                success: function(a) {
                    var i = a.data;
                    if (1 == i.result) {
                        var s = [];
                        i.data.forEach(function(t) {
                            s.push(t.id);
                        }), e.setData({
                            cup_notice: !0,
                            storeCarts: s
                        }), t.getDispatchMethod(e.data.storeCarts.toString());
                    } else e.setData({
                        cup_notice: !0
                    }), wx.showToast({
                        icon: "none",
                        title: "无商品",
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    _getStoreCartBuy: function(t) {
        var e = this, a = this, i = d.getNetAddresss("plugin.store-cashier.frontend.store.cart-buy");
        i += "&cart_ids=" + t, i += "&store_id=" + a.data.store_id, i += "&dispatch_type_id=" + this.data.selected, 
        8 == this.data.selected && (i += "&package_deliver_id=" + this.data.defaultSelfCarry.id), 
        12 == this.data.selected && (i += "&package_deliver_id=" + this.data.o2oSelfCarry.id), 
        i += "&member_coupon_ids=" + this._assembleCoupons(), i += "&orders=" + JSON.stringify(this._assembleDeduction()), 
        i += "&address=" + encodeURIComponent(JSON.stringify(this.data.currentAddress)), 
        d._getNetWork({
            url: i,
            success: function(i) {
                var s = i.data;
                if (1 == s.result) a.setData({
                    goodsInfo: s.data
                }), a._initCoupon(s.data.discount), a._setViewData(s.data, t), e.data.codeShow && e.submitBtnPost(); else {
                    if (a.setData({
                        none_loc: !1
                    }), a.data.showAddressList) return;
                    "请完善地址经纬度信息" === s.msg ? wx.showModal({
                        title: "提示",
                        content: "请完善收件人的地址经纬度信息",
                        confirmText: "确认",
                        showCancel: !1,
                        success: function(t) {
                            t.confirm;
                        }
                    }) : wx.showModal({
                        title: "提示",
                        content: s.msg,
                        confirmText: "确认",
                        showCancel: !1,
                        success: function(t) {
                            t.confirm && s.msg.indexOf("配送范围") < 0 && wx.navigateBack({
                                delta: 1
                            });
                        }
                    });
                }
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _getRentDataActionCart: function(t, e) {
        var a = this;
        if ("rentCartBuy" == this.data._root_tag) {
            var i = this, o = d.getNetAddresss("plugin.lease-toy.api.order.cart-buy");
            o += "&lease_rights=" + t, o += "&lease_term=" + e, o += "&cart_ids=" + this.data._cart_ids.toString(), 
            o += "&member_coupon_ids=" + this._assembleCoupons(), o += "&orders=" + JSON.stringify(this._assembleDeduction()), 
            o += "&address=" + encodeURIComponent(JSON.stringify(this.data.currentAddress)), 
            o += "&dispatch_type_id=" + this.data.selected, 8 == this.data.selected && (o += "&package_deliver_id=" + this.data.defaultSelfCarry.id), 
            12 == this.data.selected && (o += "&package_deliver_id=" + this.data.o2oSelfCarry.id), 
            o += "&mark=" + (this.data.options.mark ? this.data.options.mark : 0), d._getNetWork({
                url: o,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? (i.setData({
                        goodsInfo: e.data,
                        cup_notice: !0
                    }), i._initCoupon(e.data.discount), i._setViewData(e.data), a.data.codeShow && a.submitBtnPost()) : (i.setData({
                        cup_notice: !0
                    }), (0, s.default)(e.msg));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else if ("rentBuy" == this.data._root_tag) {
            var r = this, n = d.getNetAddresss("plugin.lease-toy.api.order.goods-buy");
            n += "&lease_rights=" + t, n += "&lease_term=" + e, n += "&goods_id=" + this.data._goodsId, 
            n += "&total=" + this.data._total, n += "&option_id=" + this.data._optionsId, n += "&member_coupon_ids=" + this._assembleCoupons(), 
            n += "&orders=" + JSON.stringify(this._assembleDeduction()), n += "&address=" + encodeURIComponent(JSON.stringify(this.data.currentAddress)), 
            n += "&dispatch_type_id=" + this.data.selected, 8 == this.data.selected && (n += "&package_deliver_id=" + this.data.defaultSelfCarry.id), 
            12 == this.data.selected && (n += "&package_deliver_id=" + this.data.o2oSelfCarry.id), 
            n += "&mark=" + (this.data.options.mark ? this.data.options.mark : 0), 0 == this.data.clicktag && (this.setData({
                clicktag: 1
            }), d._getNetWork({
                url: n,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? (r.setData({
                        goodsInfo: e.data,
                        cup_notice: !0
                    }), r._initCoupon(e.data.discount), r._setViewData(e.data), r.data.codeShow && r.submitBtnPost()) : (0, 
                    s.default)(e.msg), setTimeout(function() {
                        r.setData({
                            clicktag: 0
                        });
                    }, 1e3);
                },
                fail: function(t) {
                    console.log(t);
                }
            }));
        }
    },
    _getRentTimeList: function() {
        var t = this, e = d.getNetAddresss("plugin.lease-toy.api.lease-term.index");
        d._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 == a.result && t.setData({
                    rentTime: a.data.list,
                    rentFree: a.data.level.rent_free,
                    agreeCon: a.data.lease_toy_set,
                    rent_deposit_free: a.data.level.deposit_free,
                    rent_free: a.data.level.rent_free
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _rentGoodBuy: function() {
        if (this.data.isOpenRight) {
            var t = "", e = wx.getStorageSync("rentTimeRight");
            e && (t = e), this._getRentDataActionCart(t, []);
        } else if ("999" == this.data.currentIndex) {
            var a = "", i = wx.getStorageSync("rentTimeSelf");
            i && (a = i), d._isTextEmpty(a) ? this._getRentDataActionCart([], []) : this._getRentDataActionCart([], a);
        } else {
            var s = "", o = wx.getStorageSync("rentTimeChoose");
            o && (s = o), d._isTextEmpty(s) || this._getRentDataActionCart([], s);
        }
    },
    getPendingOrder_type: function() {
        var t = d.getNetAddresss("plugin.pending-order.frontend.wholesale-area.pending-order-type"), e = this;
        d._getNetWork({
            url: t,
            data: {
                small_type: 1
            },
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    if (0 == a.data.status) {
                        e.setData({
                            dispatch: [ {
                                name: "零售",
                                dispatch_type_id: 0
                            }, {
                                name: "自用",
                                dispatch_type_id: 1
                            } ],
                            selected: 0
                        });
                    } else {
                        e.setData({
                            dispatch: [ {
                                name: "自用",
                                dispatch_type_id: 1
                            } ],
                            selected: 1
                        });
                    }
                    e._getDataActionBuy();
                } else (0, s.default)(a.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    showAddress: function(t) {
        (this.setData({
            showAddressList: !0,
            addressList_caller: "express"
        }), this.data.showAddressList) && this.selectComponent("#yz_showAddressShop").setData({
            add_address: this.data.show_add_address
        });
        t.currentTarget.dataset.code && this.setData({
            codeShow: !1
        });
    },
    invoiceShowAddressFun: function() {
        this.setData({
            showAddressList: !0,
            addressList_caller: "invoice"
        });
    },
    onPeripheryChange: function(t) {
        var a = t.currentTarget.dataset.partname;
        this.setData(e({}, a, t.detail));
    },
    onClickRight: function() {
        this.setData({
            codeShow: !1,
            addressList_caller: "express"
        }), this.selectComponent("#yz_addressList").showAddAddress("iscode");
    },
    code_confirmSelectAddress: function(t) {
        var e;
        e = t.detail.loc ? t.detail.form : t.detail, console.log("addressCodeClick 多次点击控制", this.data.addressCodeClick), 
        1 != this.data.addressCodeClick && (this.data.addressCodeClick = 1, this._setAddressViewData(e), 
        this._requestByAddress());
    },
    confirmSelectAddress: function(t) {
        var e;
        e = t.detail.loc ? t.detail.form : t.detail, "express" == this.data.addressList_caller ? (this._setAddressViewData(e), 
        this._requestByAddress(), this.setData({
            showAddressList: !1
        })) : "invoice" == this.data.addressList_caller && (this.selectComponent(".invoicePop").setAddress(e), 
        this.setData({
            showAddressList: !1
        }));
    },
    _setAddressViewData: function(t) {
        var e = this;
        null != t && "" != t && t != [] && ("cake" === this.options.tag && (this.setData({
            cakeCity: t.city,
            shopDetail: "",
            shopName: "",
            shopId: ""
        }), this.getRule()), this.data.currentAddId = t.id || t.address_id, this.setData({
            currentAddress: t,
            realname: d._isTextEmpty(t.username) ? "" : t.username,
            mobile: d._isTextEmpty(t.mobile) ? "" : t.mobile,
            address: d._isTextEmpty(t.province) ? t.address ? t.address : "" : t.province + " " + t.city + " " + t.district + " " + (d._isTextEmpty(t.street) ? "" : t.street + " ") + t.address
        }), "11" != this.data.selected || t.latitude && t.longitude || d.confirm("将获取您的位置，请确定后重新提交订单", function(a) {
            a && e.autoAddress(t);
        }, !1));
    },
    autoAddress: function(t) {
        var e = t.id, a = this;
        wx.getLocation({
            type: "wgs84",
            success: function(i) {
                var s = d.qqMapTransBMap(parseFloat(i.longitude), parseFloat(i.latitude)), o = d.getNetAddresss("member.member-address.update-location");
                d._getNetWork({
                    url: o,
                    data: {
                        address_id: e,
                        latitude: s.lat,
                        longitude: s.lng
                    },
                    success: function(e) {
                        1 == e.data.result ? (t.latitude = s.lat, t.longitude = s.lng, a.setData({
                            currentAddress: t
                        })) : wx.showToast({
                            icon: "none",
                            title: "请重新编辑您的地址，在地图上选择您所在的位置",
                            duration: 1e3
                        });
                    }
                });
            },
            fail: function(t) {
                wx.showToast({
                    icon: "none",
                    title: "请重新编辑您的地址，在地图上选择您所在的位置",
                    duration: 1e3
                });
            }
        });
    },
    _assembleCoupons: function() {
        for (var t = [], e = 0; e < this.data.checkCouponList.length; e++) if (this.data.is_coupon_SELE) {
            var a = this.data.checkCouponList[e].has_conpon_id;
            t = t.concat(a.slice(0, this.data.coupons_temp[this.data.checkCouponList[e].coupon_id].num)), 
            this.setData({
                use_coupon_size: t.length
            });
        } else t.push(this.data.checkCouponList[e].id);
        return t;
    },
    _assembleDeduction: function() {
        for (var t = [], e = 0; e < this.data.checkDeductionList.length; e++) this.data.checkDeductionList[e] && t.push(this.data.checkDeductionList[e]);
        return t;
    },
    _initDiyForm: function() {
        if ("{}" == JSON.stringify(this.data.orders_goods)) {
            for (var t = {}, e = 0; e < this.data.goodsInfo.orders.length; e++) for (var a = 0; a < this.data.goodsInfo.orders[e].order_goods.length; a++) if (this.data.goodsInfo.orders[e].order_goods[a].diy_form) {
                var i = {};
                i.pre_id = this.data.goodsInfo.orders[e].order_goods[a].pre_id, i.diyform_data_id = "", 
                t[i.pre_id] = i;
            }
            this.setData({
                orders_goods: t
            });
        }
    },
    findGoodOpen: function() {
        for (var t = 0; t < this.data.goodsInfo.orders.length; t++) {
            if (this.data.goodsInfo.orders[t].camilo_resources_coupon_type && (this.setData({
                camilo_resources_coupon_type: this.data.goodsInfo.orders[t].camilo_resources_coupon_type
            }), 1 == this.data.plugin_setting.yz_supply_camilo_resources.is_default_order_address)) {
                this.setData({
                    _show_address: !0
                }), this.data.currentAddId = 1;
                var e = this.data.plugin_setting.yz_supply_camilo_resources, a = e.address, i = e.city, s = e.district, o = e.province, r = e.street, d = e.mobile, n = e.username;
                this._setAddressViewData({
                    address: a,
                    city: i,
                    district: s,
                    province: o,
                    street: r,
                    mobile: d,
                    username: n,
                    address_id: 1
                });
            }
            if (this.data.goodsInfo.orders[t].travel_around_order && 1 == this.data.plugin_setting.travel_around.is_default_order_address) {
                this.setData({
                    _show_address: !0
                }), this.data.currentAddId = 1;
                var c = this.data.plugin_setting.travel_around, h = c.address, _ = c.city, l = c.district, u = c.province, p = c.street, g = c.mobile, f = c.username;
                this._setAddressViewData({
                    address: h,
                    city: _,
                    district: l,
                    province: u,
                    street: p,
                    mobile: g,
                    username: f,
                    address_id: 1
                });
            }
            if (this.options.electricity && "electricity" == this.options.electricity && this.setData({
                electricity_Guide: this.data.goodsInfo.orders[t].order_goods[0].pre_id,
                ele_no_showAdress: !!this.data.goodsInfo.orders[t].order_goods[0] && this.data.goodsInfo.orders[0].not_show_address,
                eleUser: this.data.goodsInfo.orders[t].order_goods[0] ? this.data.goodsInfo.orders[0].user_account : ""
            }), this.data.goodsInfo.orders[t].require_mobile) {
                console.log("有商品开启话费慢充！！！");
                var m = "";
                this.data.goodsInfo.orders[t].tips && (m = this.data.goodsInfo.orders[t].tips.replace(/<img/g, '<img style="width:100%"')), 
                this.setData({
                    recharge_tips: m,
                    show_recharge_mobile: this.data.goodsInfo.orders[t].order_goods[0].pre_id
                });
            }
            this.data.oil_mobile && this.data.oil_account && (this.data.oil_pre_id = this.data.goodsInfo.orders[t].order_goods[0].pre_id);
            for (var y = 0; y < this.data.goodsInfo.orders[t].order_goods.length; y++) this.data.goodsInfo.orders[t].order_goods[y].diy_form && (console.log("有商品开启自定义表单！！！"), 
            this.data.hasGoodOpenDF = !0);
        }
    },
    _checkDiyForm: function() {
        for (var t in this.data.orders_goods) if (!this.data.orders_goods[t].diyform_data_id) return !1;
        return !0;
    },
    _setDiyForm: function(t, e) {
        for (var a in this.data.orders_goods) if (this.data.orders_goods[a].pre_id == t) return this.data.orders_goods[a].diyform_data_id = e, 
        void this.setData({
            orders_goods: this.data.orders_goods
        });
    },
    _findDiyForm: function(t) {
        for (var e in this.data.orders_goods) if (this.data.orders_goods[e].pre_id == t) return this.data.orders_goods[e].diyform_data_id;
        return !1;
    },
    _assembleDiyForm: function() {
        var t = [];
        for (var e in this.data.orders_goods) t.push(this.data.orders_goods[e]);
        return t;
    },
    onTELChange: function(t) {
        this.setData({
            recharge_mobile: t.detail
        });
    },
    assembleGoodsTELData: function() {
        var t = [], e = {};
        return "electricity" == this.options.electricity ? (e.pre_id = this.data.electricity_Guide, 
        e.account_id = this.options.account_id) : this.data.oil_account && this.data.oil_mobile ? (e.pre_id = this.data.oil_pre_id, 
        e.account = this.data.oil_account, e.mobile = this.data.oil_mobile) : (e.pre_id = this.data.show_recharge_mobile, 
        e.mobile = this.data.recharge_mobile), t.push(e), t;
    },
    _setViewData: function(t, e) {
        var a = this;
        if (this.setData({
            _show_address: this.isOrderAddress_M(t.orders),
            recommend_goods: t.dispatch.recommend_goods ? t.dispatch.recommend_goods : []
        }), t.is_agency_restock && 1 == t.is_agency_restock && this.setData({
            _show_address: !0
        }), this.data._show_address && this.setData({
            selected: 0
        }), this._setAddressViewData(t.dispatch.default_member_address), this.setData({
            consigneeName: t.dispatch.custom_data ? t.dispatch.custom_data.custom_consignee : "提货人姓名",
            consigneeMobile: t.dispatch.custom_data ? t.dispatch.custom_data.custom_phone : "提货人手机"
        }), this._initDiyForm(), t.discount && t.discount.default_deduction && 0 != t.discount.default_deduction && (this.data.default_deduction = t.discount.default_deduction), 
        0 != this.data.default_deduction) for (var i = function(e) {
            var i = t.orders[e].order_deductions;
            t.orders[e].order_deductions instanceof Array || (i = Object.values(t.orders[e].order_deductions)), 
            i.map(function(i) {
                i.checked && a._screenDiscount(t.orders[e], i);
            });
        }, s = 0; s < t.orders.length; s++) i(s);
        this.findGoodOpen(), this.data.getParams_status || (this.data.getParams_status = !0, 
        this.getParams(e)), this.checkOrders(t), this.data.dispatch.forEach(function(t, e) {
            "machine" != a.data._root_tag && (8 == t.dispatch_type_id && "{}" == JSON.stringify(a.data.defaultSelfCarry) && a._getLocation(function() {
                a.getList("shop");
            }), 12 == t.dispatch_type_id && (console.log("有门店自提点配送方式，请求定位获取自提点列表"), a.data.o2oSelfCarry.id || a._getLocation(function() {
                a.getList("o2o");
            })));
        }), this.setData({
            order_data: t.orders,
            price: t.total_price,
            total_items: t.amount_items,
            discount_amount_items: t.discount_amount_items,
            service_fee_items: t.service_fee_items,
            tax_fee_items: t.tax_fee_items,
            service: t.orders[0].order_fees,
            none_loc: !0,
            clicktag: 0
        }), "reserve" == this.data._root_tag && this.setData({
            delivery_information: t.delivery_information
        }), "store" == this.data._root_tag && this.data.price < 0 && wx.showToast({
            icon: "none",
            title: "下单错误",
            duration: 1500
        }), t.dispatch.use_wechat_address && this.setData({
            use_wechat_address: t.dispatch.use_wechat_address
        }), "11" == this.data.selected && this.data.order_data.forEach(function(t) {
            1 * a.data.cityDelivery.min_amount > 1 * t.goods_price && a.setData({
                yz_subscribe_disabled: !0
            });
        }), 1 == t.is_diy_form_jump && this.setData({
            is_diy_form_jump: t.is_diy_form_jump
        }), this.getDistributionInfo(t.last_deliver_user_info), t.address_code && this.setData({
            show_add_address: !!t.address_code.show_add_address && t.address_code.show_add_address
        });
    },
    isOrderAddress_M: function(t) {
        for (var e = 0; e < t.length; e++) if (this.data.phone_bill_pro_goods) {
            if (!t[e].not_show_address) return !1;
        } else if (this.data.oil_account && this.data.oil_mobile) {
            if (!t[e].not_show_address) return !1;
        } else if (!t[e].need_address) return console.log("有订单需要填写地址"), !1;
        return !0;
    },
    checkOrders: function(t) {
        for (var e = 0; e < t.orders.length; e++) 58 === t.orders[e].plugin_id && this.setData({
            plugin_id: 58
        });
        for (var a = 0; a < t.orders.length; a++) {
            if (!("domain" in t.orders[a])) return void this.setData({
                isDomain: !1
            });
            this.setData({
                isDomain: !0,
                domain: t.orders[a].domain
            });
        }
    },
    getParams: function(t) {
        var e, a = this, i = this;
        if ("store" != this.data._root_tag || t) {
            "store" == this.data._root_tag && t && this.setData({
                _cart_ids: t
            });
            var s = [];
            if (this.data.options.cart_ids && "undefined" != this.data.options.cart_ids && this.setData({
                _cart_ids: this.data.options.cart_ids ? JSON.parse(this.data.options.cart_ids) : []
            }), this.data.isCartsOrder) for (var o = 0; o < this.data.goodsInfo.orders.length; o++) for (var r = 0; r < this.data.goodsInfo.orders[o].order_goods.length; r++) s.push(this.data.goodsInfo.orders[o].order_goods[r].goods_id); else this.data.options.goodsId && this.setData({
                _goodsId: Number(this.data.options.goodsId)
            }), s.push(this.data._goodsId);
            var n = d.getNetAddresss("from.div-from.get-params");
            e = {
                goods_ids: JSON.stringify(s)
            }, d._getNetWork({
                url: n,
                data: e,
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        "groupBuy_open" == i.options.type && "groupBuy_join" == i.options.type || i.setData({
                            isGetAgreementPay: !0,
                            AgreementPay: e.data.getPayProtocol ? e.data.getPayProtocol : ""
                        }), a.setData({
                            freightExplain: e.data.freightExplain
                        });
                        try {
                            i.setData({
                                storeSearchBtn: e.data.storeSearch || {},
                                openCueCoupon: 0 != e.data.getCouponSet
                            }), i._checkTaxGoods(e.data.isDisplay), e.data.getMemberInfo && i._getMemberInfo(e.data.getMemberInfo), 
                            i.getInvoice(e.data.sinvoice);
                        } catch (t) {
                            console.log(t);
                        }
                    } else i.setData({
                        isGetAgreementPay: !1
                    });
                    i.data.machineId && i.setData({
                        _show_address: !0
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    getInvoice: function(t) {
        var e = {
            realname: this.data.realname,
            mobile: this.data.mobile,
            address: this.data.address
        };
        this.selectComponent(".invoicePop").initData({
            sinvoice: t,
            address: e
        });
    },
    subInvoice: function(t) {
        this.setData({
            invoice_list: t.detail
        });
    },
    _initCoupon: function(t) {
        t.deduction_lang && this.setData({
            deduction_lang: t.deduction_lang
        }), this.setData({
            isShowCoupon: "1" == t.whether_show_coupon
        });
        var e = t.member_coupons;
        if (this.setData({
            is_coupon_SELE: "1" == t.coupon_show
        }), this.setData({
            coupon_size: e.length
        }), null != e && "" != e && null != e) if (this.data.is_coupon_SELE) {
            var a = e.sort(function(t, e) {
                return t.expired_at - e.expired_at;
            });
            this.initSelectCoupon(a);
        } else this.setData({
            coupons: e
        });
    },
    defaultSelectCoupon: function(t) {
        var e = [];
        t.forEach(function(t, a) {
            1 == t.checked && e.push(t);
        }), this.setData({
            coupon_size: t.length,
            coupons: t,
            use_coupon_size: e.length,
            checkCouponList: e
        });
    },
    initSelectCoupon: function(t) {
        for (var e = t, a = [], i = {}, s = 0; s < e.length; s++) {
            var o = 0, r = 0, d = [ e[s].id ];
            e[s].checked && o++, e[s].valid && r++;
            for (var n = s + 1; n < e.length; n++) e[s].coupon_id == e[n].coupon_id && (e[n].checked && o++, 
            e[n].valid && r++, d.push(e[n].id), e.splice(n, 1), n--);
            var c = e[s];
            c.has_conpon_id = d, c.valid_num = r, a.push(c), i[e[s].coupon_id] = {}, i[e[s].coupon_id].num = o;
        }
        this.setData({
            coupons_temp: i,
            coupons: a
        });
    },
    changeConpon: function(t) {
        var e = this, a = t.target.dataset.item, i = t.detail, s = t.target.dataset.index;
        if (i > a.valid_num) return wx.showToast({
            icon: "none",
            title: "使用张数已达上限",
            duration: 1e3
        }), clearTimeout(this.data.timer), void (this.data.timer = setTimeout(function() {
            e.data.coupons_temp[a.coupon_id].num = a.valid_num, e.setData({
                coupons_temp: e.data.coupons_temp
            });
        }, 200));
        if ("" != i && null != i && 0 != i) {
            clearTimeout(this.data.timer), this.data.coupons_temp[a.coupon_id].num = i, this.setData({
                coupons_temp: this.data.coupons_temp
            });
            var o = {
                detail: !0,
                currentTarget: {
                    dataset: {
                        index: s,
                        item: a
                    }
                }
            };
            this.data.timeoutId && clearTimeout(this.data.timeoutId), this.data.timeoutId = setTimeout(function() {
                e.selectCoupon(o);
            }, 1e3);
        } else wx.showToast({
            icon: "none",
            title: "暂不使用请取消勾选",
            duration: 1e3
        });
    },
    infonamebtn: function(t) {
        var e = t.detail;
        this.setData({
            "linkinfo.name": e
        });
    },
    infonameclear: function() {
        this.setData({
            "linkinfo.name": ""
        });
    },
    infomobileclear: function() {
        this.setData({
            "linkinfo.mobile": ""
        });
    },
    infomobilebtn: function(t) {
        var e = t.detail;
        this.setData({
            "linkinfo.mobile": e
        });
    },
    _requestByAddress: function() {
        this.handleBuy(1);
    },
    _judgeIsRight: function() {
        this.data.isOpenRight ? this.setData({
            isRightChoose: !1
        }) : this.setData({
            isRightChoose: !0
        });
    },
    rentSelect: function(t) {
        var e = t.detail;
        if (this.setData({
            isOpenRight: e
        }), this._clearStorage(), this._judgeIsRight(), this.data.isOpenRight) {
            var a = [];
            this.data.order_data.forEach(function(t) {
                t.order.order_goods.forEach(function(t) {
                    var e = {
                        goods_id: t.goods_id,
                        total: t.total
                    };
                    a.push(e);
                });
            }), wx.setStorage({
                key: "rentTimeRight",
                data: JSON.stringify(a)
            }), this._getRentDataActionCart(JSON.stringify(a), []);
        } else this.data.isOpenRight || (this.setData({
            currentIndex: "999"
        }), this._getRentDataActionCart([], []));
    },
    _clearStorage: function() {
        wx.removeStorage({
            key: "rentTimeSelf"
        }), wx.removeStorage({
            key: "rentTimeChoose"
        }), wx.removeStorage({
            key: "rentTimeRight"
        });
    },
    kfeeChange: function(t) {
        var a = t.currentTarget.dataset.dindex, i = t.currentTarget.dataset.orindex, s = this.data.order_data[i].pre_id, o = t.currentTarget.dataset.kfee;
        0 == t.detail ? this.setData(e({}, "taxInclusive." + s, [ o.fee_code ])) : this.setData(e({}, "taxInclusive." + s, [])), 
        this.serviceFeesHandle(this.data.order_data[i], this.data.order_data[i].order_deductions[a]), 
        this.handleBuy(2);
    },
    switchChange: function(t) {
        var a, i, s = t.currentTarget.dataset.dindex, o = t.currentTarget.dataset.orindex, r = this.data.order_data[o].pre_id, d = t.currentTarget.dataset.item, n = t.currentTarget.dataset.codeind;
        d.checked ? this.setData((e(a = {}, "order_data[" + o + "].order_service_fees[" + n + "].checked", !1), 
        e(a, "order_data[" + o + "].order_service_fees[" + n + "].show", !1), e(a, "service_fee." + r, []), 
        a)) : this.setData((e(i = {}, "order_data[" + o + "].order_service_fees[" + n + "].checked", !0), 
        e(i, "order_data[" + o + "].order_service_fees[" + n + "].show", !0), e(i, "service_fee." + r, [ d.code ]), 
        i));
        this.serviceFeesHandle(this.data.order_data[o], this.data.order_data[o].order_deductions[s]), 
        this.handleBuy(2);
    },
    discountHandle: function(t) {
        var a = t.detail, i = t.currentTarget.dataset.dindex, s = t.currentTarget.dataset.orindex, o = t.currentTarget.dataset.tag;
        if (this.data.none_loc || (a = !1), "discount" == o) "[object Object]" == Object.prototype.toString.call(this.data.order_data[s].order_deductions) ? this.setData(e({}, "order_data[" + s + "].order_deductions." + i + ".checked", a)) : "[object Array]" == Object.prototype.toString.call(this.data.order_data[s].order_deductions) && this.setData(e({}, "order_data[" + s + "].order_deductions[" + i + "].checked", a)), 
        this._screenDiscount(this.data.order_data[s], this.data.order_data[s].order_deductions[i]); else if ("serviceFee" == o) {
            var r = this.data.order_data[s].pre_id;
            this.setData(e({}, "service_fee." + r, t.detail)), this.serviceFeesHandle(this.data.order_data[s], this.data.order_data[s].order_deductions[i]);
        }
        this.handleBuy(2);
    },
    noteHandle: function(t) {
        var a = t.target.dataset.preid, i = t.target.dataset.item, s = t.detail.value;
        this.setData(e({}, "note." + a, s)), this.deductionListHandle(i);
    },
    _screenDiscount: function(t, e) {
        this.deductionListHandle(t, e);
    },
    serviceFeesHandle: function(t, e) {
        this.deductionListHandle(t);
    },
    deductionListHandle: function(t, e) {
        var a = this.data.checkDeductionList, i = this.data.service_fee, s = this.data.taxInclusive || [], o = this.data.note, r = !1;
        a.length > 0 && a.map(function(a, d) {
            a && a.pre_id == t.pre_id && (r = !0, e && e.checked ? a.deduction_ids && -1 == a.deduction_ids.indexOf(e.code) && a.deduction_ids.push(e.code) : e && !e.checked && a.deduction_ids && a.deduction_ids.indexOf(e.code) > -1 && a.deduction_ids.splice(a.deduction_ids.indexOf(e.code), 1), 
            a.note = o[t.pre_id], a.service_fee = i[t.pre_id], a.tax_fee = s[t.pre_id]);
        }), r || a.push({
            deduction_ids: e && e.code ? [ e.code ] : [],
            pre_id: t.pre_id,
            note: o[t.pre_id],
            service_fee: i[t.pre_id],
            tax_fee: s[t.pre_id]
        }), this.setData({
            checkDeductionList: a
        });
    },
    rentSelfChoose: function() {
        this._clearStorage(), this.setData({
            currentIndex: "999"
        }), this.setData({
            rentShow: !0
        });
    },
    rentShowClose: function(t) {
        var e = this;
        if ("confirm" === t.detail) {
            if (d._isTextEmpty(this.data.tenancy)) return void wx.showToast({
                icon: "none",
                title: "租期不能为空",
                duration: 1e3
            });
            var a = {
                days: this.data.tenancy,
                lease_term_id: 0
            };
            wx.setStorage({
                key: "rentTimeSelf",
                data: JSON.stringify(a)
            }), this._getRentDataActionCart([], JSON.stringify(a)), setTimeout(function() {
                e.setData({
                    rentShow: !1
                });
            }, 1e3);
        } else this.setData({
            rentShow: !1
        }), console.log("取消自定义租期！！！");
    },
    rentShowinp: function(t) {
        var e = t.detail;
        this.setData({
            tenancy: e
        });
    },
    rentclear: function() {
        this.setData({
            tenancy: ""
        });
    },
    rentTimeChoose: function(t) {
        var e = t.currentTarget.dataset.item, a = t.currentTarget.dataset.index;
        if (this.data.currentIndex == a) this.setData({
            currentIndex: "999"
        }), this._clearStorage(), this._getRentDataActionCart([], []); else {
            this._clearStorage(), this.setData({
                currentIndex: a
            });
            var i = {
                days: 0,
                lease_term_id: e.id
            };
            wx.setStorage({
                key: "rentTimeChoose",
                data: JSON.stringify(i)
            }), this._getRentDataActionCart([], JSON.stringify(i));
        }
    },
    showCoupon: function() {
        0 != this.data.coupon_size ? this.setData({
            popupCouponSpecs: !0
        }) : wx.showToast({
            icon: "none",
            title: "暂无优惠券使用",
            duration: 1500
        });
    },
    selectCoupon: function(t) {
        var a = t.detail, i = t.currentTarget.dataset.index, s = t.currentTarget.dataset.item;
        this.setData(e({}, "coupons[" + i + "].checked", a)), this._screenCoupon(a, s, t.type), 
        this._setCouponView(), this.handleBuy(2);
    },
    _screenCoupon: function(t, e, a) {
        var i = e, s = this.data.checkCouponList;
        if (this.data.checkCouponList.length > 0) for (var o = 0; o < this.data.checkCouponList.length; o++) this.data.checkCouponList[o].id == i.id && s.splice(o, 1);
        this.data.is_coupon_SELE && a && (this.data.coupons_temp[i.coupon_id].num = t ? 1 : 0, 
        this.setData({
            coupons_temp: this.data.coupons_temp
        })), t ? s.push(i) : this.setData({
            cup_notice: !0
        }), this.setData({
            checkCouponList: s
        });
    },
    _setCouponView: function() {
        this.setData({
            use_coupon_size: this.data.checkCouponList.length
        });
    },
    mustSelectCoupon: function() {
        return !(!(this.data.openCueCoupon && this.data.coupon_size > 0 && this.data.use_coupon_size < 1) || this.data.isCueCoupon) && (this.setData({
            isCueCoupon: !0,
            popupCouponSpecs: !0
        }), !0);
    },
    couponclose: function() {
        this.setData({
            popupCouponSpecs: !1
        });
    },
    agreementbtn: function(t) {
        var e = t.detail;
        this.setData({
            agreement: e
        });
    },
    showAgreement: function() {
        this.setData({
            agreementShow: !0
        });
    },
    agreementClose: function() {
        this.setData({
            agreementShow: !1
        });
    },
    toSite: function() {
        wx.navigateTo({
            url: "/packageE/others/application_market/binding_site/binding_site?plugin_id=" + this.data.plugin_id
        });
    },
    getTemplate: function(t) {
        var e = d.getNetAddresss("member.member.getMiniTemplateCorrespond"), a = this;
        d._getNetWork({
            url: e,
            data: {
                small_type: 1
            },
            success: function(e) {
                var i = e.data;
                if (1 == i.result) {
                    for (var o = [], r = 0; r < i.data.length; r++) o.push(i.data[r].template_id);
                    a.setData({
                        TemplateArray: o
                    }), a.data.TemplateArray.length > 0 ? wx.requestSubscribeMessage({
                        tmplIds: a.data.TemplateArray,
                        success: function(e) {
                            a.setData({
                                clickMiniTemplate: !0
                            }), a.submitBtn(t);
                        },
                        fail: function(e) {
                            a.submitBtn(t);
                        }
                    }) : a.submitBtn(t);
                } else (0, s.default)(i.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    submit: function() {
        var t = !!this.data.address_codeEnable;
        this.data.yz_subscribe_disabled || (this.data.clickMiniTemplate ? this.submitBtn(t) : this.getTemplate(t));
    },
    getDiyForm: function() {
        this.setData({
            codeShow: !0
        });
        var t = this.selectComponent("#yz_showAddress");
        t.code_editAddress(this.data.currentAddress), t.getIsOpenAddress();
    },
    onClickLeft: function() {
        this.setData({
            codeShow: !1
        });
    },
    checkDispatch: function() {
        var t = this;
        if ("machine" == this.data._root_tag) return !0;
        if (8 == this.data.selected || 12 == this.data.selected || 15 == this.data.selected) {
            if (d._isTextEmpty(this.data.linkinfo.name)) return wx.showModal({
                title: "提示",
                content: "请填写提货人姓名",
                showCancel: !1,
                confirmText: "确定",
                confirmColor: "#000000",
                success: function(t) {}
            }), this.data.submit_active = !0, !1;
            if (d._isTextEmpty(this.data.linkinfo.mobile)) return wx.showModal({
                title: "提示",
                content: "请输入提货人手机",
                showCancel: !1,
                confirmText: "确定",
                confirmColor: "#000000",
                success: function(t) {}
            }), this.data.submit_active = !0, !1;
        }
        if (8 == this.data.selected || 12 == this.data.selected) {
            if (8 == this.data.selected && d._isTextEmpty(this.data.defaultSelfCarry) || 12 == this.data.selected && d._isTextEmpty(this.data.o2oSelfCarry)) return wx.showToast({
                title: "该地区暂无自提点",
                duration: 1e3,
                icon: "none"
            }), !1;
            if (8 == this.data.selected && d._isTextEmpty(this.data.defaultSelfCarry.id) || 12 == this.data.selected && d._isTextEmpty(this.data.o2oSelfCarry.id)) return wx.showModal({
                title: "提示",
                content: "请选择自提点",
                showCancel: !1,
                confirmText: "确定",
                confirmColor: "#000000",
                success: function(t) {}
            }), this.data.submit_active = !0, !1;
            var e = {
                distributionUserName: this.data.linkinfo.name ? this.data.linkinfo.name : "",
                distributionUserMobile: this.data.linkinfo.mobile ? this.data.linkinfo.mobile : ""
            };
            try {
                wx.setStorageSync("selfCarryInfo", JSON.stringify(e));
            } catch (t) {
                console.log(t);
            }
        }
        if (1 == this.data.store_info.delivery_information) {
            if ("2" == this.data.selected && (d._isTextEmpty(this.data.linkinfo.name) || d._isTextEmpty(this.data.linkinfo.mobile))) return wx.showToast({
                icon: "none",
                title: "请输入提货人信息",
                duration: 1500
            }), !1;
            if ("2" == this.data.selected && !/^[0-9]{1,}$/.test(this.data.linkinfo.mobile)) return wx.showToast({
                icon: "none",
                title: "请输入正确的联系电话",
                duration: 1500
            }), this.data.submit_active = !0, !1;
        }
        if (!(this.data._show_address || 0 != this.data.selected && 1 != this.data.selected && 3 != this.data.selected || this.data.ele_no_showAdress || this.data.reserve_order)) {
            if ((0 == this.data.selected || 1 == this.data.selected) && this.data.use_wechat_address) return d._isTextEmpty(this.data.design_info.userName) ? (d.tips("请输入收货人姓名"), 
            this.data.submit_active = !0, !1) : d._isTextEmpty(this.data.design_info.telNumber) ? (d.tips("请填写收货手机号"), 
            this.data.submit_active = !0, !1) : d._isTextEmpty(this.data.userAdress) ? (d.tips("请选择所在区域"), 
            this.data.submit_active = !0, !1) : !d._isTextEmpty(this.data.design_address) || (d.tips("请输入街道、楼牌号等"), 
            this.data.submit_active = !0, !1);
            if (d._isTextEmpty(this.data.currentAddId) && "machine" !== this.data._root_tag) return wx.showModal({
                title: "提示",
                content: "请选择收货地址",
                showCancel: !1,
                confirmText: "确定",
                confirmColor: "#000000",
                success: function(e) {
                    t.showAddress();
                }
            }), this.data.submit_active = !0, !1;
        }
        return !0;
    },
    checkSubmit: function() {
        if (this.mustSelectCoupon()) return !1;
        if (this.data.isDomain && d._isTextEmpty(this.data.domain)) return wx.showToast({
            icon: "none",
            title: "请绑定站点",
            duration: 1500
        }), !1;
        if ("1" == this.data.cpstype && "" == this.data.cpsTxt) return wx.showToast({
            title: "请输入帐号",
            duration: 1e3,
            icon: "none"
        }), !1;
        if (this.data.show_recharge_mobile && !this.data.recharge_mobile) return wx.showToast({
            icon: "none",
            title: "请输入充值手机号码！",
            duration: 1500
        }), !1;
        if (this.data.show_recharge_mobile && this.data.recharge_mobile) {
            if (!/^[1][0-9]{10}$/.test(this.data.recharge_mobile)) return wx.showToast({
                icon: "none",
                title: "请输入正确的充值手机号码！",
                duration: 1500
            }), !1;
        }
        if (null != this.data.reserve_order) {
            if ("" == this.data.reserve_tel_name) return d.tips("请输入联系人");
            if ("" == this.data.reserve_mobile) return d.tips("请输入联系电话");
        }
        if (1 == this.data.camilo_resources_coupon_type && !this.data.recharge_number) return d.tips("请输入充值账号");
        if ("newRetail" == this.options.tag && 3 == this.options.retailState && 0 == this.data.price) return wx.showToast({
            icon: "none",
            title: "价格有误",
            duration: 1500
        }), this.data.submit_active = !0, !1;
        if (this.data.hasGoodOpenDF && !this._checkDiyForm()) {
            if (0 == this.data.is_diy_form_jump) return wx.showToast({
                icon: "none",
                title: "请先填写表单",
                duration: 1500
            }), this.data.submit_active = !0, !1;
            if (1 == this.data.is_diy_form_jump) for (var t = this.data.order_data, e = 0; e < t.length; e++) for (var a = 0; a < t[e].order_goods.length; a++) if (!t[e].order_goods[a].diy_form.diyform_data_id) return this.showDyForm(t[e].order_goods[a].diy_form.form_id, t[e].order_goods[a].pre_id), 
            !1;
        }
        return !!this.checkDispatch() && (!this.data.AgreementPay || this.data.isRent || this.data.agreementPay ? !(this.data.isRent && !this.data.agreement) || (wx.showToast({
            icon: "none",
            title: "请勾选租赁协议",
            duration: 1500
        }), this.data.submit_active = !0, !1) : (wx.showToast({
            icon: "none",
            title: "请勾选支付协议",
            duration: 1500
        }), !1));
    },
    showDyForm: function(t, e) {
        if (this.setData({
            "diyform.form_id": t,
            "diyform.pre_id": e
        }), this._findDiyForm(e)) {
            var a = this._findDiyForm(e);
            this.setData({
                "diyform.diyform_data_id": a
            });
        }
        this.setData({
            diyShow: !0
        });
    },
    submitBtn: function() {
        var t, e, a = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];
        this.checkSubmit() && ((1 != (null === (t = this.data.plugin_setting) || void 0 === t || null === (e = t.travel_around) || void 0 === e ? void 0 : e.is_default_order_address) || "tourAround" != this.data._root_tag) && a && 1 == this.data.selected ? this.getDiyForm() : this.submitBtnPost());
    },
    submitBtnPost: function() {
        var t = this, e = this._assembleJson();
        if (this.data.store_id && "reserve" != this.options.tag) {
            if (this.isHasInstall()) {
                if (!this.data.installDate) return void d.tips("请选择预约时间！");
                if (!this.data.location && !this.data.location.latitude) return void d.tips("请选择地理位置！");
                var a = {
                    live_install: {
                        longitude: this.data.location.longitude,
                        latitude: this.data.location.latitude,
                        reserve_time: this.data.installDate,
                        install_comment: this.data.install_comment
                    }
                };
                Object.assign(e, a);
            }
            this.data.order_url = "plugin.store-cashier.frontend.store.create";
        }
        if ("tourAround" === this.options.tag) {
            if (d._isTextEmpty(this.data.customerPhoneNumber)) return wx.showToast({
                icon: "none",
                title: "请输入正确的联系电话",
                duration: 1500
            }), !1;
            if (d._isTextEmpty(this.data.customerName)) return wx.showToast({
                icon: "none",
                title: "请输入姓名",
                duration: 1500
            }), !1;
            if (d._isTextEmpty(this.data.idCard)) return wx.showToast({
                icon: "none",
                title: "请输入身份证号码",
                duration: 1500
            }), !1;
            e.customerName = this.data.customerName, e.customerPhoneNumber = this.data.customerPhoneNumber, 
            e.memo = this.data.memo, e.idCard = this.data.idCard;
        }
        if ("cake" === this.options.tag) {
            if (d._isTextEmpty(this.data.cakeMoblie)) return wx.showToast({
                icon: "none",
                title: "请输入订货人手机号",
                duration: 1500
            }), !1;
            if ("delivery" === this.data.cakeShipType || "shop" === this.data.cakeShipType) {
                if (d._isTextEmpty(this.data.cakeShipDate)) return wx.showToast({
                    icon: "none",
                    title: "请选择配送日期",
                    duration: 1500
                }), !1;
                if (d._isTextEmpty(this.data.shipTimeText)) return wx.showToast({
                    icon: "none",
                    title: "请选择配送时间",
                    duration: 1500
                }), !1;
            }
            e.dispatch_type_id = 0, e.city_cake = this.data.cakeCity, e.cake_ship_type = this.data.cakeShipType, 
            e.ship_date = this.data.cakeShipDate, e.ship_time_text = this.data.shipTimeText, 
            e.buyer_phone = this.data.cakeMoblie, "1" !== this.data.canTake && 1 !== this.data.canTake || (e.cake_shop_id = this.data.shopId, 
            e.cake_shop_detail = this.data.shopDetail, e.cake_shop_name = this.data.shopName);
        }
        switch (this.data._root_tag) {
          case "store_projects_goods":
            this.data.order_url = "plugin.store-projects.frontend.order.create", e.goods_type = "store_projects_goods", 
            this.data.options.exchange_code_id && (this.data.order_other_json = {
                exchange_code_id: this.data.options.exchange_code_id
            }, this.data.pre_order_url = "plugin.exchange-code.api.goods-buy");
        }
        if ("10" == this.data.selected && e.supplier_driver_distribution_address && (d._isTextEmpty(e.supplier_driver_distribution_address.lat) || d._isTextEmpty(e.supplier_driver_distribution_address.lng))) d.tips("请选择供应商配送定位"); else {
            if ("11" == this.data.selected) {
                if (3 == this.data.cityDelivery.distance_type) {
                    if (!this.data.cityDelivery_community.id) return void d.tips("请选择配送社区");
                    e.community_id = this.data.cityDelivery_community.id;
                }
                if (1 == this.data.cityDelivery.future_state) {
                    if (!this.data.cityDelivery_deliveryTime.start_time || !this.data.cityDelivery_deliveryTime.end_time) return void d.tips("请选择配送时间");
                    e.expect_start_time = this.data.cityDelivery_deliveryTime.start_time, e.expect_end_time = this.data.cityDelivery_deliveryTime.end_time;
                }
            }
            if (1 == this.data.submit_active) {
                this.data.submit_active = !1;
                var i = "", o = d.getNetAddresss(this.data.order_url);
                0 == this.data.clicktag && (this.setData({
                    clicktag: 1
                }), d._postNetWork({
                    url: o,
                    showToastIn: !1,
                    data: e,
                    success: function(e) {
                        var a = e.data;
                        if (t.data.submit_active = !0, 1 == a.result) {
                            t.setData({
                                showPage: !1
                            }), wx.showLoading({
                                title: "跳转中"
                            });
                            try {
                                wx.setStorageSync("selfCarryInfo", {});
                            } catch (t) {
                                console.log(t);
                            }
                            if (t.data.iscps) return void wx.redirectTo({
                                url: "../orderPay/orderPay?order_id=" + a.data.order_ids + "&status=2" + "&iscps=".concat(!!t.data.iscps)
                            });
                            if (t.options.option_level_id) {
                                var o = "groups";
                                return t.options.plu && "ywm" == t.options.plu && (o = "ywmGroup"), i = "../orderPay/orderPay?order_id=" + a.data.order_ids + "&status=2&name=" + o, 
                                void wx.redirectTo({
                                    url: i
                                });
                            }
                            if (t.data.store_id) return void wx.redirectTo({
                                url: "../orderPay/orderPay?order_id=" + a.data.order_ids + "&status=2&store_id=" + t.data.store_id
                            });
                            if ("blindBox" == t.data._root_tag) return void wx.redirectTo({
                                url: "../orderPay/orderPay?order_id=" + a.data.order_ids + "&status=2&name=" + t.data._root_tag
                            });
                            if ("tourAround" == t.data._root_tag) {
                                var r = {
                                    ordersn: a.data.order_sn,
                                    api: "plugin.travel-around.frontend.payment.payment",
                                    name: t.data._root_tag
                                }, d = "../orderPay/orderPay?ordersn=".concat(r.ordersn, "&status=2&tag=").concat(r.name, "&api=").concat(r.api);
                                return void wx.redirectTo({
                                    url: d
                                });
                            }
                            wx.redirectTo({
                                url: "../orderPay/orderPay?order_id=" + a.data.order_ids + "&status=2"
                            });
                        } else (0, s.default)(a.msg);
                        setTimeout(function() {
                            t.setData({
                                clicktag: 0,
                                addressCodeClick: 0
                            });
                        }, 1e3);
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                }));
            }
        }
    },
    isHasInstall: function() {
        for (var t = 0; t < this.data.goodsInfo.service_fee_items.length; t++) if ("liveInstall" == this.data.goodsInfo.service_fee_items[t].code) return !0;
        return !1;
    },
    inpCpsTxt: function(t) {
        var e = t.detail.value;
        this.setData({
            cpsTxt: e
        });
    },
    _assembleGoods: function() {
        for (var t = [], e = 0; e < this.data.goodsInfo.orders.length; e++) for (var a = 0; a < this.data.goodsInfo.orders[e].order_goods.length; a++) {
            var i = {};
            i.goods_id = this.data.goodsInfo.orders[e].order_goods[a].goods_id, i.total = this.data.goodsInfo.orders[e].order_goods[a].total, 
            i.option_id = this.data.goodsInfo.orders[e].order_goods[a].goods_option_id, t.push(i);
        }
        return t;
    },
    _assembleJson: function() {
        var t = {
            address: encodeURIComponent(JSON.stringify(this.data.currentAddress)),
            goods: JSON.stringify(this._assembleGoods()),
            member_coupon_ids: JSON.stringify(this._assembleCoupons()),
            orders: JSON.stringify(this._assembleDeduction()),
            invoice: this.data.invoice_list,
            mark: this.data.options.mark ? this.data.options.mark : 0,
            dispatch_type_id: this.data.selected
        };
        if (this.data.use_wechat_address && (1 == this.data.selected || 0 == this.data.selected && !this.data.use_wechat_address)) {
            var e = {
                address: this.data.design_address || "",
                city: this.data.design_info.cityName,
                district: this.data.design_info.countyName,
                id: "",
                isdefault: "",
                latitude: "",
                longitude: "",
                mobile: this.data.design_info.telNumber,
                province: this.data.design_info.provinceName,
                street: "",
                uid: "",
                uniacid: "",
                username: this.data.design_info.userName,
                zipcode: ""
            };
            t.address = e.address ? encodeURIComponent(JSON.stringify(e)) : [];
        }
        if (this.data.activity_id && (t.activity_id = this.data.activity_id), this.options.share_uid && (t.share_uid = this.options.share_uid), 
        this.data.hasGoodOpenDF && (t.order_goods = this._assembleDiyForm()), this.data.show_recharge_mobile && (t.order_goods = JSON.stringify(this.assembleGoodsTELData())), 
        "electricity" == this.options.electricity && (t.order_goods = JSON.stringify(this.assembleGoodsTELData())), 
        this.data.oil_account && this.data.oil_mobile && (t.order_goods = JSON.stringify(this.assembleGoodsTELData())), 
        "1" == this.data.cpstype && (t.recharge_number = this.data.cpsTxt), 1 == this.data.camilo_resources_coupon_type && (t.recharge_number = this.data.recharge_number), 
        t = this.handleDataActionBuyUrl(t, "order"), t = this.handleDataActionCartUrl(t, "order"), 
        "store" == this.data._root_tag) t.store_id = this.data.store_id, t.mobile = this.data.linkinfo.mobile, 
        t.realname = this.data.linkinfo.name, t.cart_ids = JSON.stringify(this.data.storeCarts); else if ("rentCartBuy" == this.data._root_tag || "rentBuy" == this.data._root_tag) {
            var a = wx.getStorageSync("rentTimeRight") || "", i = wx.getStorageSync("rentTimeChoose") || "", s = wx.getStorageSync("rentTimeSelf") || "", o = {};
            d._isTextEmpty(i) ? d._isTextEmpty(s) || (o = s) : o = i, t.lease_rights = null == d._isTextEmpty(a) ? [] : a, 
            t.lease_term = o, t.cart_ids = JSON.stringify(this.data._cart_ids);
        }
        if ((2 == this.data.selected || 8 == this.data.selected || 12 == this.data.selected || 15 == this.data.selected) && (t.mobile = this.data.linkinfo.mobile, 
        t.realname = this.data.linkinfo.name, "o2oDeposit" === this.data._root_tag)) {
            this.data.currentAddId = 1;
            var r = this.data.store_info.store_address.split(" ");
            this._setAddressViewData({
                province: r[0],
                city: r[1],
                district: r[2],
                street: r[3],
                address: r[4],
                mobile: this.data.store_info.store_mobile,
                username: this.data.store_info.store_name,
                address_id: 1
            }), t.address = encodeURIComponent(JSON.stringify(this.data.currentAddress));
        }
        return 8 != this.data.selected && 12 != this.data.selected || (t.package_deliver_id = 8 == this.data.selected ? this.data.defaultSelfCarry.id : this.data.o2oSelfCarry.id, 
        delete t.address), 3 == this.data.selected && (t.mobile = this.data.store_info.store_mobile, 
        t.realname = this.data.store_info.store_name), 10 == this.data.selected && (t.supplier_driver_distribution_address = this.data.supp_point), 
        Object.assign(t, this.data.orderLocationObj), t;
    },
    agreementPaybtn: function(t) {
        var e = t.detail;
        this.setData({
            agreementPay: e
        });
    },
    showPay: function() {
        this.setData({
            agreementPayShow: !0
        });
    },
    showPayClose: function() {
        this.setData({
            agreementPayShow: !1
        });
    },
    diyFromEdit: function(t) {
        if (this.setData({
            "diyform.form_id": t.detail.form_id,
            "diyform.pre_id": t.detail.preid
        }), this._findDiyForm(t.currentTarget.dataset.preid)) {
            var e = this._findDiyForm(t.currentTarget.dataset.preid);
            this.setData({
                "diyform.diyform_data_id": e
            });
        }
        this.setData({
            diyShow: !0,
            codeShow: !1
        });
    },
    showDiy: function(t) {
        if (this.setData({
            "diyform.form_id": t.currentTarget.dataset.id,
            "diyform.pre_id": t.currentTarget.dataset.preid
        }), this._findDiyForm(t.currentTarget.dataset.preid)) {
            var e = this._findDiyForm(t.currentTarget.dataset.preid);
            this.setData({
                "diyform.diyform_data_id": e
            });
        }
        this.setData({
            diyShow: !0
        });
    },
    showDiyClose: function() {
        this.setData({
            diyShow: !1
        });
    },
    traCheckedData: function(t) {
        this._setDiyForm(t.detail.pre_id, t.detail.diyform_data_id), this.showDiyClose();
    },
    getList: function(t) {
        var e = this, a = this, i = t, s = d.getNetAddresss("plugin.package-deliver.frontend.deliver.getList");
        "o2o" == i && (s = d.getNetAddresss("plugin.package-deliver.frontend.store.deliver.getList"));
        var o = d.qqMapTransBMap(parseFloat(a.data.point.lng), parseFloat(a.data.point.lat));
        d._getNetWork({
            url: s,
            data: {
                city_name: a.data.city,
                lat: o.lat,
                lng: o.lng,
                kwd: "",
                goods: JSON.stringify(this._assembleGoods()),
                store_id: this.data.options.store_id || 0,
                deliver_id: this.options.package_deliver_id || ""
            },
            success: function(t) {
                var s = t.data;
                1 == s.result ? "shop" == i ? a.setData({
                    deliverName: s.data.name,
                    defaultSelfCarry: "{}" == JSON.stringify(a.data.defaultSelfCarry) ? s.data.list.data[0] : a.data.defaultSelfCarry
                }) : "o2o" == i && (e.data.o2oSelfCarry.id || e.setData({
                    o2odeliverName: s.data.name,
                    o2oSelfCarry: s.data.list.data[0] ? s.data.list.data[0] : ""
                })) : wx.showToast({
                    icon: "none",
                    title: "获取自提点失败",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getCurrentOrderLocation: function() {
        var t = this;
        wx.getLocation({
            type: "gcj02",
            success: function(e) {
                var a = e.latitude, i = e.longitude;
                t._setOrderLocation({
                    lat: a,
                    lng: i
                });
            }
        });
    },
    _setOrderLocation: function(t) {
        var e = this;
        d.getReverseGeocoder(t.lat, t.lng).then(function(t) {
            var a = t.address_component, i = {
                positioning_success: 1,
                province: a.province,
                city: d._isTextEmpty(a.city) ? a.province : a.city
            };
            e.data.orderLocationObj = i;
        }).catch(function(t) {
            console.log(t);
        });
    },
    checkAlbum: function(t) {
        var e = this;
        return i(a.default.mark(function i() {
            var s;
            return a.default.wrap(function(a) {
                for (;;) switch (a.prev = a.next) {
                  case 0:
                    return a.next = 2, e.getAuthSetting(t);

                  case 2:
                    return s = a.sent, a.abrupt("return", new Promise(function(e, a) {
                        s ? e(!0) : wx.showModal({
                            title: "请开启授权",
                            content: "是否跳转设置页开启授权",
                            success: function(a) {
                                a.confirm ? wx.openSetting({
                                    success: function(a) {
                                        a.authSetting[t] ? e(!0) : e(!1);
                                    }
                                }) : a.cancel && e(!1);
                            },
                            fail: function() {
                                e(!1);
                            }
                        });
                    }));

                  case 4:
                  case "end":
                    return a.stop();
                }
            }, i);
        }))();
    },
    getAuthSetting: function(t) {
        return new Promise(function(e, a) {
            wx.getSetting({
                success: function(a) {
                    a.authSetting[t] ? e(!0) : wx.authorize({
                        scope: t,
                        success: function() {
                            e(!0);
                        },
                        fail: function() {
                            e(!1);
                        }
                    });
                },
                fail: function() {
                    e(!1);
                }
            });
        });
    },
    toO2oSearchDiyBtn: function() {
        try {
            wx.redirectTo({
                url: this.data.storeSearchBtn.app_url
            });
        } catch (t) {
            console.log(t);
        }
    },
    toFullPage: function() {
        if (this.data._root_tag == this.data.TAG_ACTION_BUY) {
            var t = d.getNetAddresss("postageIncludedCategory.member-cart.store");
            d._postNetWork({
                url: t,
                data: {
                    goods_id: this.data._goodsId,
                    total: this.data._total || 1,
                    option_id: this.data._optionsId || 0
                },
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        var a = [];
                        a.push(Number(e.data.cart_id)), wx.navigateTo({
                            url: "/packageE/orderullPackage/orderullPackage?cart_id=" + JSON.stringify(a)
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else this.data._root_tag == this.data.TAG_ACTION_CART && wx.navigateTo({
            url: "/packageE/orderullPackage/orderullPackage?cart_id=" + this.options.cart_ids
        });
    },
    onChange: function(t) {
        this.setData({
            sexSelect: t.detail
        });
    },
    cell_from_inp: function(t) {
        "name" == t.currentTarget.dataset.key && this.setData({
            "design_info.userName": t.detail.value
        }), "phone" == t.currentTarget.dataset.key && this.setData({
            "design_info.telNumber": t.detail.value
        }), "adress" == t.currentTarget.dataset.key && this.setData({
            design_address: t.detail.value,
            "design_info.detailInfo": t.detail.value
        }), this.data.use_wechat_address && this.data.userAdress && this.data.design_address && (this.data.design_info.detailInfo || this.data.design_info.telNumber || this.data.design_info.userName) && this._requestByAddress();
    },
    tapShowArea: function() {
        this.setData({
            showArea: !0
        });
    },
    confirmArea: function(t) {
        this.setData({
            userAdress: "".concat(t.detail[0].name, " ").concat(t.detail[1].name, " ").concat(t.detail[2].name),
            "design_info.provinceName": t.detail[0].name,
            "design_info.cityName": t.detail[1].name,
            "design_info.countyName": t.detail[2].name
        }), this.data.use_wechat_address && this.data.userAdress && this.data.design_address && (this.data.design_info.detailInfo || this.data.design_info.telNumber || this.data.design_info.userName) && this._requestByAddress();
    },
    changeCityDeliveryCommunity: function(t) {
        this.setData({
            cityDelivery_community_id: t.detail
        });
    },
    setCityDeliveryCommunity: function() {
        var t = this, e = this.data.cityDelivery.community_setting.community_list.find(function(e) {
            return e.id == t.data.cityDelivery_community_id;
        });
        this.setData({
            cityDelivery_community: e,
            selectCommunityShow: !1
        });
    },
    openCityDeliveryDay: function() {
        this.selectComponent(".deliveryTime").setPopShow();
    },
    cityDeliveryDayConfirm: function(t) {
        this.setData({
            cityDelivery_deliveryTime: t.detail
        }), this.handleBuy();
    },
    getDistributionInfo: function() {
        var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null, e = t || {}, a = e.mobile, i = e.realname, s = {
            distributionUserMobile: a,
            distributionUserName: i
        }, o = Object.keys(wx.getStorageSync("selfCarryInfo")), r = 0 != o.length ? JSON.parse(wx.getStorageSync("selfCarryInfo")) : {};
        this.setData({
            "linkinfo.name": 0 != o.length ? r.distributionUserName : s.distributionUserName || "",
            "linkinfo.mobile": 0 != o.length ? r.distributionUserMobile : s.distributionUserMobile || ""
        });
    }
});